Results 1 to 8 of 8

Thread: anyone know how i can just delete a text file?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    anyone know how i can just delete a text file?

    e.g, if I want to delete C:\test.txt

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: anyone know how i can just delete a text file?

    VB Code:
    1. Kill "c:\test.txt"

  3. #3
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: anyone know how i can just delete a text file?

    in case the file doesn't exist...

    VB Code:
    1. On Error Resume Next
    2. Kill "c:\peanutbutter.txt"

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: anyone know how i can just delete a text file?

    And to avoid trapping/ignoring errors:

    VB Code:
    1. Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileW" ( _
    2.     ByVal lpFileName As Long _
    3. ) As Long
    4.  
    5. ' Usage:
    6. DeleteFile StrPtr("C:\test.txt")

  5. #5
    Lively Member FYRe's Avatar
    Join Date
    Aug 2005
    Location
    Singapore
    Posts
    102

    Re: anyone know how i can just delete a text file?

    Quote Originally Posted by Pouncer
    e.g, if I want to delete C:\test.txt

    Here:

    IO.File.Delete("C:\test.txt")

    sOMEONE'S gONNA dO iT, wHY nOT yOU ?

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: anyone know how i can just delete a text file?

    Quote Originally Posted by FYRe
    Here:

    IO.File.Delete("C:\test.txt")

    1) Only if you are using VB.NET

    2) Only if you have imported the System namespace


  7. #7
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: anyone know how i can just delete a text file?

    Quote Originally Posted by FYRe
    Here:

    IO.File.Delete("C:\test.txt")

    That seems to be for .Net
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  8. #8
    Lively Member FYRe's Avatar
    Join Date
    Aug 2005
    Location
    Singapore
    Posts
    102

    Red face Re: anyone know how i can just delete a text file?

    Oops..... sorry.
    I've been browsing too many webpages in this forum, to have noticed that I actually posted here.. =)

    FYRe
    sOMEONE'S gONNA dO iT, wHY nOT yOU ?

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