首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C#惯用目录操作总结

2013-03-21 
C#常用目录操作总结在C#中,常用的目录操作类有Directory, DirectoryInfo,基本上两个类提供的方法大同小异,

C#常用目录操作总结

在C#中,常用的目录操作类有Directory, DirectoryInfo,基本上两个类提供的方法大同小异,有不算太大的区别,但是Directory类是静态类,所有的函数都是静态函数,可以直接调用。


使用Directory可以创建指定的目录,删除目录,获取目录信息,例如创建时间等,获取目录中的子目录,获取目录中的文件集合等操作,还可以设置目录的访问时间等。


简单的一个目录操作的代码,判断目录是否存在,如果不存在则创建目录:

C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结CreateDirectory(String)Creates all directories and subdirectories as specified by C#惯用目录操作总结CreateDirectory(String, DirectorySecurity)Creates all the directories in the specified path, applying the specified Windows security.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结Delete(String)Deletes an empty directory from a specified path.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结Delete(String, Boolean)Deletes the specified directory and, if indicated, any subdirectories and files in the directory.C#惯用目录操作总结C#惯用目录操作总结EnumerateDirectories(String)Returns an enumerable collection of directory names in a specified path.C#惯用目录操作总结C#惯用目录操作总结EnumerateDirectories(String, String)Returns an enumerable collection of directory names that match a search pattern in a specified path.C#惯用目录操作总结C#惯用目录操作总结EnumerateDirectories(String, String, SearchOption)Returns an enumerable collection of directory names that match a search pattern in a specified path, and optionally searches subdirectories.C#惯用目录操作总结C#惯用目录操作总结EnumerateFiles(String)Returns an enumerable collection of file names in a specified path.C#惯用目录操作总结C#惯用目录操作总结EnumerateFiles(String, String)Returns an enumerable collection of file names that match a search pattern in a specified path.C#惯用目录操作总结C#惯用目录操作总结EnumerateFiles(String, String, SearchOption)Returns an enumerable collection of file names that match a search pattern in a specified path, and optionally searches subdirectories.C#惯用目录操作总结C#惯用目录操作总结EnumerateFileSystemEntries(String)Returns an enumerable collection of file-system entries in a specified path.C#惯用目录操作总结C#惯用目录操作总结EnumerateFileSystemEntries(String, String)Returns an enumerable collection of file-system entries that match a search pattern in a specified path.C#惯用目录操作总结C#惯用目录操作总结EnumerateFileSystemEntries(String, String, SearchOption)Returns an enumerable collection of file names and directory names that match a search pattern in a specified path, and optionally searches subdirectories.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结ExistsDetermines whether the given path refers to an existing directory on disk.C#惯用目录操作总结C#惯用目录操作总结GetAccessControl(String)Gets a DirectorySecurity object that encapsulates the access control list (ACL) entries for a specified directory.C#惯用目录操作总结C#惯用目录操作总结GetAccessControl(String, AccessControlSections)Gets a DirectorySecurity object that encapsulates the specified type of access control list (ACL) entries for a specified directory.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结GetCreationTimeGets the creation date and time of a directory.C#惯用目录操作总结C#惯用目录操作总结GetCreationTimeUtcGets the creation date and time, in Coordinated Universal Time (UTC) format, of a directory.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结GetCurrentDirectoryGets the current working directory of the application.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结GetDirectories(String)Gets the names of subdirectories in the specified directory.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结GetDirectories(String, String)Gets an array of directories matching the specified search pattern from the current directory.C#惯用目录操作总结C#惯用目录操作总结GetDirectories(String, String, SearchOption)Gets an array of directories matching the specified search pattern from the current directory, using a value to determine whether to search subdirectories.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结GetDirectoryRootReturns the volume information, root information, or both for the specified path.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结GetFiles(String)Returns the names of files (including their paths) in the specified directory.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结GetFiles(String, String)Returns the names of files (including their paths) that match the specified search pattern in the specified directory.C#惯用目录操作总结C#惯用目录操作总结GetFiles(String, String, SearchOption)Returns the names of files (including their paths) that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结GetFileSystemEntries(String)Returns the names of all files and subdirectories in the specified directory.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结GetFileSystemEntries(String, String)Returns an array of file system entries that match the specified search criteria.C#惯用目录操作总结C#惯用目录操作总结GetFileSystemEntries(String, String, SearchOption)Gets an array of all the file names and directory names that match a search pattern in a specified path, and optionally searches subdirectories.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结GetLastAccessTimeReturns the date and time the specified file or directory was last accessed.C#惯用目录操作总结C#惯用目录操作总结GetLastAccessTimeUtcReturns the date and time, in Coordinated Universal Time (UTC) format, that the specified file or directory was last accessed.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结GetLastWriteTimeReturns the date and time the specified file or directory was last written to.C#惯用目录操作总结C#惯用目录操作总结GetLastWriteTimeUtcReturns the date and time, in Coordinated Universal Time (UTC) format, that the specified file or directory was last written to.C#惯用目录操作总结C#惯用目录操作总结GetLogicalDrivesRetrieves the names of the logical drives on this computer in the form "<drive letter>:\".C#惯用目录操作总结C#惯用目录操作总结GetParentRetrieves the parent directory of the specified path, including both absolute and relative paths.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结MoveMoves a file or a directory and its contents to a new location.C#惯用目录操作总结C#惯用目录操作总结SetAccessControlApplies access control list (ACL) entries described by a DirectorySecurity object to the specified directory.C#惯用目录操作总结C#惯用目录操作总结SetCreationTimeSets the creation date and time for the specified file or directory.C#惯用目录操作总结C#惯用目录操作总结SetCreationTimeUtcSets the creation date and time, in Coordinated Universal Time (UTC) format, for the specified file or directory.C#惯用目录操作总结C#惯用目录操作总结C#惯用目录操作总结SetCurrentDirectorySets the application's current working directory to the specified directory.C#惯用目录操作总结C#惯用目录操作总结SetLastAccessTimeSets the date and time the specified file or directory was last accessed.C#惯用目录操作总结C#惯用目录操作总结SetLastAccessTimeUtcSets the date and time, in Coordinated Universal Time (UTC) format, that the specified file or directory was last accessed.C#惯用目录操作总结C#惯用目录操作总结SetLastWriteTimeSets the date and time a directory was last written to.C#惯用目录操作总结C#惯用目录操作总结SetLastWriteTimeUtcSets the date and time, in Coordinated Universal Time (UTC) format, that a directory was last written to.Top

热点排行