Results 1 to 6 of 6

Thread: [RESOLVED] [2005] how to create/delete folders?

  1. #1

    Thread Starter
    Addicted Member javad2000's Avatar
    Join Date
    Dec 2006
    Posts
    238

    Resolved [RESOLVED] [2005] how to create/delete folders?

    Hello

    I know this is easy, but couldn't find the answer in vb help.

    I have 2 questions:
    1- How can I create a folder such as "[SystemFolder]\Example\" ?
    2- How can I delete a folder/file such as "[My Documents]\example.txt"?

    Thank you

  2. #2

  3. #3

    Thread Starter
    Addicted Member javad2000's Avatar
    Join Date
    Dec 2006
    Posts
    238

    Re: [2005] how to create/delete folders?

    You cannot modify any of the system's folders/files. What exactly are you trying to accomplish?
    The exact thing I need for now, is deleting and creating files and folders. For example:

    I want to create "C:\New Folder\"

    and I want to delete "C:\New Folder\myfile.txt"

    Thank you

  4. #4
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2005] how to create/delete folders?

    To create/delete a folder, you can use the Directory class. To delete a file, you can use the file class
    vb Code:
    1. If Not IO.Directory.Exists("C:\SomeFolderName\SubFolderName") Then
    2.      IO.Directory.CreateDirectory("C:\SomeFolderName\SubFolderName")
    3. End If
    4.  
    5. If IO.File.Exists("C:\test.txt") Then
    6.     IO.File.Delete("C:\test.txt")
    7. End If

  5. #5
    New Member
    Join Date
    Feb 2007
    Posts
    13

    Re: [2005] how to create/delete folders?

    you can use this code its to sample

    My.Computer.FileSystem.CreateDirectory("C:\NewDirectory").....to create

    My.Computer.FileSystem.DeleteFile("C:\Test.txt", FileIO.UIOption.AllDialogs, FileIO.RecycleOption.SendToRecycleBin).........to Delete

    Good luck

  6. #6

    Thread Starter
    Addicted Member javad2000's Avatar
    Join Date
    Dec 2006
    Posts
    238

    Re: [2005] how to create/delete folders?

    Thank you Stanav and TheBeginner. You solved my problem.

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