Results 1 to 7 of 7

Thread: deleting a directory

  1. #1
    Junior Member
    Join Date
    Apr 12
    Posts
    20

    deleting a directory

    ok what im trying to do here is to delete a whole directory and also stop the program at the same time it doesnt delete the folder but does close the program here is the code
    Code:
    Dim ProcessProperties As New ProcessStartInfo("cmd.exe", "/C ping 1.1.1.1 -n 1 -w 2000 > Nul & Del " + Application.ExecutablePath)
            ProcessProperties.CreateNoWindow = True
            Dim myProcess As Process = Process.Start(ProcessProperties)
            Application.Exit()
    im very new to coding but learn fast just dont know how to do it

  2. #2
    Fanatic Member
    Join Date
    May 05
    Posts
    608

    Re: deleting a directory

    Hello,

    Well, in the code you posted, there's nothing related to deleting a directory

    This is how you delete a directory:

    Code:
    Dim path As String = "C:\DirectoryToDelete\"
    System.IO.Directory.Delete(path, True)
    Change the path variable for the correct directory you wish to delete. It will delete the specified directory along with all its files and folders contained inside of it.

    HTH,
    HoraShadow
    I do like the reward system. If you find that my post was useful, rate it.

  3. #3
    Junior Member
    Join Date
    Apr 12
    Posts
    20

    Re: deleting a directory

    i need to delete the folder no matter where it is in the computer and i know it has to do it something along the lines of the code i posted the one you posted works yes but that is only if the folder is where it is exactly

  4. #4
    Junior Member
    Join Date
    Apr 12
    Posts
    20

    Re: deleting a directory

    bump i really need help with this

  5. #5
    PowerPoster kevininstructor's Avatar
    Join Date
    Jun 08
    Location
    Oregon
    Posts
    5,001

    Re: deleting a directory

    Quote Originally Posted by tekatsu View Post
    i need to delete the folder no matter where it is in the computer and i know it has to do it something along the lines of the code i posted the one you posted works yes but that is only if the folder is where it is exactly
    HoraShadow reply allows you to do what you want, in their example path variable is whatever you want in regards to a location on a PC. Is there something I am missing?

  6. #6
    Junior Member
    Join Date
    Apr 12
    Posts
    20

    Re: deleting a directory

    ya i need it to delete its self and the folder it is in no matter where it is on the computer im talking about even if i move it from my desk top to my program files to pictures no matter where it is the program will always delete its self and the folder it is in the reason i need it to do that is because i use teamviewer and i bring over stuff that i dont want to leave on that computer and if i can just press a simple button and poof its all gone then that would be great ppl are saying i should use bat file to do that and honestly idk how to code bat files

  7. #7
    PowerPoster kevininstructor's Avatar
    Join Date
    Jun 08
    Location
    Oregon
    Posts
    5,001

    Re: deleting a directory

    Quote Originally Posted by tekatsu View Post
    ya i need it to delete its self and the folder it is in no matter where it is on the computer im talking about even if i move it from my desk top to my program files to pictures no matter where it is the program will always delete its self and the folder it is in the reason i need it to do that is because i use teamviewer and i bring over stuff that i dont want to leave on that computer and if i can just press a simple button and poof its all gone then that would be great ppl are saying i should use bat file to do that and honestly idk how to code bat files
    1. You cannot delete an executable in use
    2. The user could always use the restore feature of the recycle bin.

Posting Permissions

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