If inside my code, I opened a text file using
Open "a.txt" for Input at #1
How do I erase the file if I decided to cancel the operation after this statement and before the Close #1?
Printable View
If inside my code, I opened a text file using
Open "a.txt" for Input at #1
How do I erase the file if I decided to cancel the operation after this statement and before the Close #1?
No direct ways, you can go to the immediate window and close it there, and then delete the file. Or you can shell dos to unlock your harddrive and then delete it, don't know if that works but windows have locked all opened files.
You mean, open a txt file and delete everything inside?
Open "C:\[Text file]" For Output Shared As #1 'Read or Write
Print #1, "" 'Write nothing erasing file completely
Close #1 'Close it
Is that what you meant?
[Edited by Matthew Gates on 05-16-2000 at 03:56 PM]
Nope... I want to completely delete the file from my harddisk.
Hello trisLOGIC,
Use this source:
Private Sub Form_Load()
Dim DelText As String
DelText = "c:\q.txt"
Open DelText For Output Shared As #1 'Read or Write
Print #1, "test" 'Write nothing erasing file completely
Close #1 'Close it
If Dir(DelText) <> "" Then Kill (DelText)
End Sub
Good luck,
Michelle.