Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Win32 API Command

Status
Not open for further replies.

ryan

Programmer
Nov 13, 2000
73
US
Just wondering if anyone knew the API command, if there is one, that opens up a plan file and removes a line that matches the string you pass. All I want to do is take a standard file like:

1
2
3
4
5

and delete the number 3 and then the file would then render:

1
2
4
5

Any ideas, does an API exist for this?

Thanks,
Ryan
 
If I have do such operations I generally use the Scripting.FileSystemObject and its associated Objects. For example you could do something like:

Dim FSO as New FileSystemObject
Dim inFile as TextStream
Dim outFile as TextStream
dim strLine as string

set inFile = FSO.OpenTextFile(&quot;<your file name&quot;>,True)
set outFile = FSO.CreateTextFile(&quot;<temp File&quot;>,ForWriting)

While not inFile.AtEndOfStream
strLine = inFile.ReadLine()
if instr(1,strLine,&quot;3&quot;) = 0 then
outFile.Writeline(strLine)
end if
wend

inFile.Close
outFile.Close

FSO.DeleteFile &quot;<your file name>&quot;
FSO.MoveFile &quot;<temp file&quot;>,&quot;<your file name>&quot;

etc

I hope this is of some use to you ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top