|
-
Jan 21st, 2002, 12:43 AM
#1
Thread Starter
Junior Member
Clearing Out a Text File
Hello again! I've got a question which I think is probably pretty simple. I've got a text file called "prefs.ini." I just need to clear its contents. I think it contains 6 lines or so, and I just want to clear 'em all out. Here's my code:
Private Sub clearfile(ByVal location)
Dim writer As StreamWriter = New StreamWriter(location)
'I want to clear all contents of this file
End Sub
Thanks!
Sincerely,
Reid V. Plumbo
[email protected]
-
Jan 21st, 2002, 06:12 AM
#2
Hyperactive Member
I guess the easiest way would be to just ooen it with a filemode of create
For example.
VB Code:
Dim objWriter As New _
IO.FileStream("c:\Test.txt", _
IO.FileMode.Create, _
IO.FileAccess.Write)
objWriter.Close()
-
Jan 27th, 2002, 08:20 AM
#3
Junior Member
Just out of curiosity. Wouldn't it be easier to delete the file and then recreate it later (in code where you need it)?
-
Jan 27th, 2002, 12:53 PM
#4
Thread Starter
Junior Member
Yup. That's what I eventually did. I used Kill("myfile.ini") and that did the trick.
Reid
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
|