.NET IO library learning

xiaoxiao2021-03-06  40

Directory can realize copy, delete, move, create, and rename DirectoryInfo to achieve copy, delete, move, create, and rename the difference between the two classes: Directory's methods are static methods, if your operation is One-time, then you can consider using Directory, otherwise you can use DirectoryInfo. Note: (By default, all users will get all access rights to the new directory.) Below is the example: Imports SystemImports System.io

Public class directoryInfo1 public class limited = "g: / mydoc / msdn learning note / IO / tempdir1" DIM DESTNATION AS STRING = "g: / mydoc / msdn learning note / IO / tempdir2" if Directory. Exists (source) = false then directory.CreateDirectory (source) end if if Directory.Exists (destnation) then directory.delete (destnation) end if Directory.Move (source, destnation) File.CreateText (destnation "/ myfile.txt" ) End Sub End Class Note: The MOVE method can implement the rename function. Delete deleted directory is not placed in the recycle bin if you want to use the DirectoryInfo class, you must be a directoryInfo instance, use the directory name as a parameter, such as DIM DI As DirectoryInfo = New DirectoryInfo ("C: / Temp") Can refer to MSDN

转载请注明原文地址:https://www.9cbs.com/read-76331.html

New Post(0)