|
-
Nov 29th, 2006, 05:35 PM
#1
Thread Starter
Junior Member
Remove String From File
Hello,
I have some code that reads each line of a fixed width flat file file, and if a line is found where the length of the string > 384, it writes the line to a text file.
The other step that I need to take is to delete the line from the source file. The code is as follows;
-*****************************************
Public Sub Main()
'find the records where the string length is greater than 384
'write them out to a file
'delete them from the source file
Dim oFile As System.IO.File
Dim oRead As System.IO.StreamReader
Dim oWrite As System.IO.StreamWriter
Dim LineIn As String
oRead = oFile.OpenText("C:\Learning\SettlementDataTest\SC15_Copies\SingleFile\CDNSC.CDNSC.SC00015.11062006")
oWrite = oFile.CreateText("C:\Learning\SettlementDataTest\SC15_Copies\ErrantRecords\ErrantRecords.txt")
While oRead.Peek <> -1
LineIn = oRead.ReadLine()
If Len(LineIn) > 384 Then
oWrite.WriteLine(LineIn)
'what do I do here to delete the 'LineIn' from the source file?
End If
End While
oRead.Close()
oWrite.Close()
oFile = Nothing
LineIn = Nothing
Dts.TaskResult = Dts.Results.Success
End Sub
-*************************************
What would I do to delete the 'LineIn' found in the condition? By the way, I'm doing this in a Script Task of a Integration Services package.
Thank you for your help!
cdun2
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|