Results 1 to 5 of 5

Thread: Deleting opened text files.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Location
    Malaysia
    Posts
    69
    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?

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Guest
    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]

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Location
    Malaysia
    Posts
    69
    Nope... I want to completely delete the file from my harddisk.

  5. #5
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width