wheitalia.blogg.se

Vb net 2010 console application get startuppath
Vb net 2010 console application get startuppath











vb net 2010 console application get startuppath vb net 2010 console application get startuppath

Imports System.IOModule Module1 Public Sub StreamDemo_1() Dim InFile As String = IO.Path.Combine(Application.StartupPath, "Data.csv") Dim OutFile As String = IO.Path.Combine(Application.StartupPath, "Test.csv") If Not IO.File.Exists(OutFile) Then IO.File.Create(OutFile).Dispose() End If For x As Int32 = 0 To 6 Console.WriteLine(x) Dim Writer As New System.IO.StreamWriter(OutFile, True) Using Reader As StreamReader = New StreamReader(InFile) Dim line As String line = Reader.ReadLine Do While (Not line Is Nothing) Writer.WriteLine(line) line = Reader.ReadLine Loop End Using Writer.Close() Next Console.WriteLine("Done") End SubEnd Module Any ways the main diff between this and the one above is the method to read in the file.Īnd note I am cycling thru the one file 6 times on purpose, you would cycle once. I am not showing the Replace but using the example above you can get the idea. Imports System.IOModule Module1 Public Sub StreamDemo() Dim InFileName As String = IO.Path.Combine(Application.StartupPath, "DataIn.txt") Dim OutFileName As String = IO.Path.Combine(Application.StartupPath, "DataOut.txt") Dim Lines = IO.File.ReadAllLines(InFileName) Using Writer As StreamWriter = New StreamWriter(OutFileName) For Each line In Lines Writer.WriteLine(line.Replace("'", "").Replace(Chr(0), "").Replace(Chr(1), "")) Next End Using End SubEnd ModuleĪnother example were I took several hundred MB file and appended it to a new file. Be sure to adjust the InFileName and OutFileName variables as needed. Here is a sample that reads all data then loops thru each line, writes to a new file and replacing chars as it writes. Read the data in chunks and for each loop reading and writing the scrubbed line. This code is probably reading the whole file and keeping it in memory. This code is working well when i am running these on small filesīut i get a target invocation error when i run this on large files ie >100MBĭim file As New System. Here is my code to replace a few characters using the Visual Studio 2010(SSIS Script component).













Vb net 2010 console application get startuppath