CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Deleting Files

  1. #1
    Join Date
    Oct 2000
    Location
    Upstate NY
    Posts
    249

    Deleting Files

    With the following code generating a file how would one delete just the Individual array elements from the file and not delete the whole file. One can make each element = "" and save it but that still leaves the element with nothing in it. The above also leaves the (txt) Icon in place.

    Private Sub Sorter()

    For Y = 0 To 20
    If SeqNo = Y Then Sources(Y) = Text1.Text: Combo1.List(Y) = Sources(Y): Typ(Y) = Text2.Text: Number(Y) = Text3.Text: Amount(Y) = Text4.Text: Rate(Y) = Text5.Text: DateIn(Y) = Text6.Text: DateOut(Y) = Text7.Text: SeqNum(Y) = Text8.Text
    Next Y
    Call FILER
    End Sub

    Private Sub FILER()
    Close #1
    Open "c:\Windows\Accounts.txt" For Output As #1

    For Y = 0 To 20
    Write #1, Sources(Y), Typ(Y), Number(Y), Amount(Y), Rate(Y), DateIn(Y), DateOut(Y), SeqNum(Y)
    Next Y

    Close #1
    End Sub


  2. #2
    Join Date
    Mar 2000
    Posts
    145

    Re: Deleting Files

    Anytime you open a file "for Output As...", you're really deleting the entire contents of the file. So, if you issue the commands

    Open "c:\Windows\Accounts.txt" for Output as #1
    Close #1



    you'll have a zero-byte (empty) file. The (txt) icon will be visible until you completely delete the file.


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

Featured