[Note text] Introduction to the My.Computer.FileSystem folder operations

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")

  1.       If My.Computer.FileSystem.DirectoryExists("c:test") Then
  2.           MsgBox ( "directory c: test exist")
  3.       Else
  4.           MsgBox ( "directory c: test does not exist")
  5.       End If

Copy the code

2. Create a directory
My.Computer.FileSystem.CreateDirectory ( "full directory path")

  1.       'Check the directory exists
  2.       If My.Computer.FileSystem.DirectoryExists("c:test") Then
  3.           MsgBox ( "directory c: test exist")
  4.       Else
  5.       'Does not exist on the establishment
  6.          My.Computer.FileSystem.CreateDirectory("c:test")
  7.          MsgBox ( "directory c: test to establish") 
  8.      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.

  1.       'Check the directory exists
  2.       If My.Computer.FileSystem.DirectoryExists("c:test") Then
  3.           'Exist, remove
  4.           'Is set to delete the directory and its files and subdirectories under
  5.           My.Computer.FileSystem.DeleteDirectory("c:test", FileIO.DeleteDirectoryOption.DeleteAllContents)
  6.           MsgBox ( "directory c: test to delete")
  7.       Else
  8.           MsgBox ( "directory c: test exist") 
  9.      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)

  1.       'Check the directory exists
  2.       If My.Computer.FileSystem.DirectoryExists("c:test") Then
  3.           'Presence on the copy
  4.           When not return exception 'to cover all of the files to copy settings, press the Cancel
  5.           My.Computer.FileSystem.CopyDirectory("c:test","c:复制test",True,FileIO.UICancelOption.DoNothing)
  6.           MsgBox ( "directory c: test to copy")
  7.       Else
  8.           MsgBox ( "directory c: test exist") 
  9.      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)

  1.       'Check the directory exists
  2.       If My.Computer.FileSystem.DirectoryExists("c:test") Then
  3.           'Moves present
  4.           When not return exception 'to cover all the documents setting move, press the Cancel
  5.           My.Computer.FileSystem.CopyDirectory("c:test","c:移动test",True,FileIO.UICancelOption.DoNothing)
  6.           MsgBox ( "directory c: test to move")
  7.       Else
  8.           MsgBox ( "directory c: test exist") 
  9.      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


Guess you like

Origin www.cnblogs.com/chinatrump/p/11467103.html