Abstract: [Notes text] My.Computer.FileSystem folder Operating Guide
Demand
namespace : Microsoft.VisualBasic.MyServices
categories : FileSystemProxy (provides access to FileSystem's)
components : Visual Basic execution phase libraries (in Microsoft.VisualBasic.dll)
1. Check the directory exists
My.Computer.FileSystem.DirectoryExists ( "full directory path")
- If My.Computer.FileSystem.DirectoryExists("c:test") Then
- MsgBox ( "directory c: test exist")
- Else
- MsgBox ( "directory c: test does not exist")
- End If
Copy the code
2. Create a directory
My.Computer.FileSystem.CreateDirectory ( "full directory path")
- 'Check the directory exists
- If My.Computer.FileSystem.DirectoryExists("c:test") Then
- MsgBox ( "directory c: test exist")
- Else
- 'Does not exist on the establishment
- My.Computer.FileSystem.CreateDirectory("c:test")
- MsgBox ( "directory c: test to establish")
- End If
Copy the code
3. Delete the directory
My.Computer.FileSystem.DeleteDirectory ( "full directory path", the delete option parameter)
Delete option parameters , reference links
DeleteDirectoryOption enumerated type: Specify if you want to delete a directory that contains files or directories, it should be how to deal with. The default value is DeleteDirectoryOption.DeleteAllContents .
UIOption enumerated type: Specify whether visual tracking the progress of the job. The default value is UIOption.OnlyErrorDialogs . Necessary items.
RecycleOption enumerated type: Specify whether deleted files should be transferred to the [ Recycle Bin ]. The default value is RecycleOption.DeletePermanently .
UICancelOption enumerated type: Specify if users click [ Cancel ], whether an exception is thrown. Necessary items.
- 'Check the directory exists
- If My.Computer.FileSystem.DirectoryExists("c:test") Then
- 'Exist, remove
- 'Is set to delete the directory and its files and subdirectories under
- My.Computer.FileSystem.DeleteDirectory("c:test", FileIO.DeleteDirectoryOption.DeleteAllContents)
- MsgBox ( "directory c: test to delete")
- Else
- MsgBox ( "directory c: test exist")
- End If
Copy the code
4. Copy the directory
My.Computer.FileSystem.CopyDirectory ( "To copy a directory," "to copy the location," whether to overwrite an existing file, when you press the Cancel whether Renghui exception)
- 'Check the directory exists
- If My.Computer.FileSystem.DirectoryExists("c:test") Then
- 'Presence on the copy
- When not return exception 'to cover all of the files to copy settings, press the Cancel
- My.Computer.FileSystem.CopyDirectory("c:test","c:复制test",True,FileIO.UICancelOption.DoNothing)
- MsgBox ( "directory c: test to copy")
- Else
- MsgBox ( "directory c: test exist")
- End If
Copy the code
5. Mobile Directory
My.Computer.FileSystem.MoveDirectory ( "source path to move", "move to the target path", whether to overwrite an existing file, if canceled when pressed back into the exceptions)
- 'Check the directory exists
- If My.Computer.FileSystem.DirectoryExists("c:test") Then
- 'Moves present
- When not return exception 'to cover all the documents setting move, press the Cancel
- My.Computer.FileSystem.CopyDirectory("c:test","c:移动test",True,FileIO.UICancelOption.DoNothing)
- MsgBox ( "directory c: test to move")
- Else
- MsgBox ( "directory c: test exist")
- End If
Copy the code
Briefly above
I have been on is finishing in 2009. NCIS Information Center research station of the VB forum
Posted over.
================================================== ==
There are some things in respect of it as a kind of memory ...
a kind of memory any time the wind slowly erode slowly drift on ........
======= ============================================
~ ~ ~ Please support point Blogs, little ad beneath it ~ ~ ~
Original: Large column [note text] My.Computer.FileSystem folder Operating Guide