The user lacks necessary permissions to view the path ( SecurityException). The path exceeds the system-defined maximum length ( PathTooLongException).Ī file or directory name in the path contains a colon (:) or is in an invalid format ( NotSupportedException). The path is not valid because it is Nothing ( ArgumentNullException).ĭirectory does not exist ( DirectoryNotFoundException).ĭirectory points to an existing file ( IOException). The path is not valid for one of the following reasons: it is a zero-length string, it contains only white space, it contains invalid characters, or it is a device path (starts with \\.\) ( ArgumentException). The following conditions may cause an exception: The following example returns all files in the directory and adds them to ListBox1. Use one of the FileSystem.GetFiles method overloads, supplying the name and path of the directory to search in the directory parameter. To include subdirectories in the search, set the searchType parameter to SearchOption.SearchAllSubDirectories.Īn empty collection is returned if no files matching the specified pattern are found. You can use the wildCards parameter to specify a search pattern. Use the GetFiles(String, SearchOption, String) overload to specify additional options for your search. Use the GetFiles(String) overload for a simple file search in a specified directory, without searching subdirectories. The overloads of the FileSystem.GetFiles method return a read-only collection of strings representing the names of the files within a directory:
0 Comments
Leave a Reply. |