Windows get all files in directory что это

Directory. Get Files Метод

Определение

Возвращает имена файлов, соответствующих указанным критериям. Returns the names of files that meet specified criteria.

Перегрузки

Возвращает имена файлов (с указанием пути к ним) в указанном каталоге. Returns the names of files (including their paths) in the specified directory.

Возвращает имена файлов (включая пути) из указанного каталога, отвечающие условиям заданного шаблона поиска. Returns the names of files (including their paths) that match the specified search pattern in the specified directory.

Возвращает имена файлов (включая пути) в указанном каталоге, соответствующих заданному шаблону поиска и параметрам перечисления. Returns the names of files (including their paths) that match the specified search pattern and enumeration options in the specified directory.

Возвращает имена файлов (включая пути) в заданном каталоге, отвечающие условиям шаблона поиска, используя значение, которое определяет, выполнять ли поиск в подкаталогах. 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.

GetFiles(String)

Возвращает имена файлов (с указанием пути к ним) в указанном каталоге. Returns the names of files (including their paths) in the specified directory.

Параметры

Относительный или абсолютный путь к каталогу для поиска. The relative or absolute path to the directory to search. В этой строке не учитывается регистр знаков. This string is not case-sensitive.

Возвращаемое значение

Массив полных имен (включая пути) файлов в указанном каталоге или пустой массив, если файлы не найдены. An array of the full names (including paths) for the files in the specified directory, or an empty array if no files are found.

Исключения

path — это имя файла. path is a file name.

-или- -or- Произошла сетевая ошибка. A network error has occurred.

У вызывающего объекта отсутствует необходимое разрешение. The caller does not have the required permission.

path представляет собой строку нулевой длины, содержащую только пробелы или один или несколько недопустимых символов. path is a zero-length string, contains only white space, or contains one or more invalid characters. Вы можете запросить недопустимые символы с помощью метода GetInvalidPathChars(). You can query for invalid characters by using the GetInvalidPathChars() method.

path имеет значение null . path is null .

Указанный путь, имя файла или оба значения превышают максимальную длину, заданную в системе. The specified path, file name, or both exceed the system-defined maximum length.

Указанный путь не найден или является недопустимым (например, ведет на несопоставленный диск). The specified path is not found or is invalid (for example, it is on an unmapped drive).

Примеры

В следующем примере показано, как использовать GetFiles метод для возврата имен файлов из заданного пользователем расположения. The following example demonstrates how to use the GetFiles method to return file names from a user-specified location. Этот пример настроен для перехвата всех ошибок, общих для данного метода. The example is configured to catch all errors common to this method.

Комментарии

EnumerateFilesМетоды и GetFiles отличаются следующим образом: при использовании EnumerateFiles можно начать перечисление коллекции имен перед возвратом всей коллекции; при использовании GetFiles необходимо дождаться возвращения всего массива имен, прежде чем можно будет получить доступ к массиву. The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array. Поэтому при работе с множеством файлов и каталогов EnumerateFiles может быть более эффективным. Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.

Возвращаемые имена файлов добавляются к заданному path параметру. The returned file names are appended to the supplied path parameter.

Этот метод идентичен GetFiles(String, String) символу звездочки ( * ), заданному в качестве шаблона поиска. This method is identical to GetFiles(String, String) with the asterisk (*) specified as the search pattern.

path Параметр может указывать сведения относительного или абсолютного пути. The path parameter can specify relative or absolute path information. Сведения об относительном пути интерпретируется как относительно текущего рабочего каталога. Relative path information is interpreted as relative to the current working directory. Сведения о получении текущего рабочего каталога см. в разделе GetCurrentDirectory . To obtain the current working directory, see GetCurrentDirectory.

Порядок возвращаемых имен файлов не гарантируется; Используйте Sort метод, если требуется конкретный порядок сортировки. The order of the returned file names is not guaranteed; use the Sort method if a specific sort order is required.

path Параметр не учитывает регистр. The path parameter is not case-sensitive.

Список общих задач ввода-вывода см. в разделе Общие задачи ввода-вывода. For a list of common I/O tasks, see Common I/O Tasks.

Применяется к

GetFiles(String, String)

Возвращает имена файлов (включая пути) из указанного каталога, отвечающие условиям заданного шаблона поиска. Returns the names of files (including their paths) that match the specified search pattern in the specified directory.

Параметры

Относительный или абсолютный путь к каталогу для поиска. The relative or absolute path to the directory to search. В этой строке не учитывается регистр знаков. This string is not case-sensitive.

Строка поиска, которая должна сравниваться с именами файлов в path . The search string to match against the names of files in path . Этот параметр может содержать сочетание допустимого литерального пути и подстановочного символа (* и ?), но не поддерживает регулярные выражения. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn’t support regular expressions.

Возвращаемое значение

Массив полных имен (включая пути) файлов в указанном каталоге, которые соответствуют указанному шаблону поиска, или пустой массив, если файлы не найдены. An array of the full names (including paths) for the files in the specified directory that match the specified search pattern, or an empty array if no files are found.

Исключения

path — это имя файла. path is a file name.

-или- -or- Произошла сетевая ошибка. A network error has occurred.

У вызывающего объекта отсутствует необходимое разрешение. The caller does not have the required permission.

path представляет собой строку нулевой длины, содержащую только пробелы или один или несколько недопустимых символов. path is a zero-length string, contains only white space, or contains one or more invalid characters. Вы можете запросить недопустимые символы с помощью GetInvalidPathChars(). You can query for invalid characters by using GetInvalidPathChars().

-или- -or- searchPattern не содержит допустимый шаблон. searchPattern doesn’t contain a valid pattern.

Параметр path или searchPattern имеет значение null . path or searchPattern is null .

Указанный путь, имя файла или оба значения превышают максимальную длину, заданную в системе. The specified path, file name, or both exceed the system-defined maximum length.

Читайте также:  Windows сброс прав доступа

Указанный путь не найден или является недопустимым (например, ведет на несопоставленный диск). The specified path is not found or is invalid (for example, it is on an unmapped drive).

Примеры

В следующем примере подсчитывается количество файлов, начинающихся с указанной буквы. The following example counts the number of files that begin with the specified letter.

Комментарии

Возвращаемые имена файлов добавляются к указанному path параметру, а порядок возвращаемых имен файлов не гарантируется; используйте метод, Sort Если требуется конкретный порядок сортировки. The returned file names are appended to the supplied path parameter and the order of the returned file names is not guaranteed; use the Sort method if a specific sort order is required.

searchPattern может быть сочетанием литеральных символов и подстановочных знаков, но не поддерживает регулярные выражения. searchPattern can be a combination of literal and wildcard characters, but it doesn’t support regular expressions. В могут быть использованы следующие подстановочные знаки searchPattern . The following wildcard specifiers are permitted in searchPattern .

Спецификатор подстановочного знака Wildcard specifier Соответствует Matches
* * * (asterisk) Ноль или более символов в этой должности. Zero or more characters in that position.
? ? (вопросительный знак) (question mark) Ноль или один символ в этой позиции. Zero or one character in that position.

Символы, отличные от подстановочных знаков, являются литеральными символами. Characters other than the wildcard are literal characters. Например, searchPattern строка « * t» ищет все имена в path конце буквы «t». For example, the searchPattern string «*t» searches for all names in path ending with the letter «t». searchPattern Строка «s * » ищет все имена в path начале с буквой «s». The searchPattern string «s*» searches for all names in path beginning with the letter «s».

searchPattern не может заканчиваться двумя точками («..») или содержать две точки («..»), за которыми следует DirectorySeparatorChar или AltDirectorySeparatorChar , и не может содержать недопустимые символы. searchPattern cannot end in two periods («..») or contain two periods («..») followed by DirectorySeparatorChar or AltDirectorySeparatorChar, nor can it contain any invalid characters. Вы можете запросить недопустимые символы с помощью метода GetInvalidPathChars. You can query for invalid characters by using the GetInvalidPathChars method.

При использовании символа-шаблона звездочки в searchPattern таком формате, как * . txt, число символов в указанном расширении влияет на поиск следующим образом: When you use the asterisk wildcard character in a searchPattern such as «*.txt», the number of characters in the specified extension affects the search as follows:

  • Если указанное расширение имеет длину ровно три символа, метод возвращает файлы с расширениями, которые начинаются с указанного расширения. If the specified extension is exactly three characters long, the method returns files with extensions that begin with the specified extension. Например, » * . xls» возвращает «book.xls» и «book.xlsx». For example, «*.xls» returns both «book.xls» and «book.xlsx».
  • Во всех остальных случаях метод возвращает файлы, которые точно соответствуют указанному расширению. In all other cases, the method returns files that exactly match the specified extension. Например, » * . AI» возвращает «File.AI», но не «File. AIF». For example, «*.ai» returns «file.ai» but not «file.aif».

Если используется символ-шаблон вопросительного знака, этот метод возвращает только файлы, соответствующие указанному расширению файла. When you use the question mark wildcard character, this method returns only files that match the specified file extension. Например, при наличии двух файлов «file1.txt» и «file1.txtOther» в каталоге шаблон поиска «File?». txt «возвращает только первый файл, а шаблон поиска» file * . txt «возвращает оба файла. For example, given two files, «file1.txt» and «file1.txtother», in a directory, a search pattern of «file?.txt» returns just the first file, whereas a search pattern of «file*.txt» returns both files.

Так как этот метод проверяет имена файлов как в формате имени файла 8,3, так и в формате длинного имени файла, шаблон поиска, аналогичный » * 1 * . txt», может возвращать непредвиденные имена файлов. Because this method checks against file names with both the 8.3 file name format and the long file name format, a search pattern similar to «*1*.txt» may return unexpected file names. Например, использование шаблона поиска » * 1 * . txt» возвращает «longfilename.txt», так как формат имени файла эквивалентной 8,3 — «лонгфи

1.TXT». For example, using a search pattern of «*1*.txt» returns «longfilename.txt» because the equivalent 8.3 file name format is «LONGFI

EnumerateFilesМетоды и GetFiles отличаются следующим образом: при использовании EnumerateFiles можно начать перечисление коллекции имен перед возвратом всей коллекции; при использовании GetFiles необходимо дождаться возвращения всего массива имен, прежде чем можно будет получить доступ к массиву. The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array. Поэтому при работе с множеством файлов и каталогов EnumerateFiles может быть более эффективным. Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.

path Параметр может указывать сведения относительного или абсолютного пути. The path parameter can specify relative or absolute path information. Сведения об относительном пути интерпретируется как относительно текущего рабочего каталога. Relative path information is interpreted as relative to the current working directory. Сведения о получении текущего рабочего каталога см. в разделе GetCurrentDirectory . To obtain the current working directory, see GetCurrentDirectory.

path Параметр не учитывает регистр. The path parameter is not case-sensitive.

Список общих задач ввода-вывода см. в разделе Общие задачи ввода-вывода. For a list of common I/O tasks, see Common I/O Tasks.

Применяется к

GetFiles(String, String, EnumerationOptions)

Возвращает имена файлов (включая пути) в указанном каталоге, соответствующих заданному шаблону поиска и параметрам перечисления. Returns the names of files (including their paths) that match the specified search pattern and enumeration options in the specified directory.

Параметры

Относительный или абсолютный путь к каталогу для поиска. The relative or absolute path to the directory to search. В этой строке не учитывается регистр знаков. This string is not case-sensitive.

Строка поиска, которая будет сравниваться с именами подкаталогов в path . The search string to match against the names of subdirectories in path . Этот параметр может содержать сочетание допустимых литеральных и подстановочных символов, но не поддерживает регулярные выражения. This parameter can contain a combination of valid literal and wildcard characters, but it doesn’t support regular expressions.

Объект, описывающий конфигурацию поиска и перечисления для использования. An object that describes the search and enumeration configuration to use.

Возвращаемое значение

Массив полных имен (включая пути) файлов в указанном каталоге, которые соответствуют заданному шаблону поиска и параметрам перечисления, или пустой массив, если файлы не найдены. An array of the full names (including paths) for the files in the specified directory that match the specified search pattern and enumeration options, or an empty array if no files are found.

Исключения

path — это имя файла. path is a file name.

-или- -or- Произошла сетевая ошибка. A network error has occurred.

У вызывающего объекта отсутствует необходимое разрешение. The caller does not have the required permission.

path представляет собой строку нулевой длины, содержащую только пробелы или один или несколько недопустимых символов. path is a zero-length string, contains only white space, or contains one or more invalid characters. Вы можете запросить недопустимые символы с помощью GetInvalidPathChars(). You can query for invalid characters by using GetInvalidPathChars().

-или- -or- searchPattern не содержит допустимый шаблон. searchPattern doesn’t contain a valid pattern.

Параметр path или searchPattern имеет значение null . path or searchPattern is null .

Указанный путь, имя файла или оба значения превышают максимальную длину, заданную в системе. The specified path, file name, or both exceed the system-defined maximum length.

Указанный путь не найден или является недопустимым (например, ведет на несопоставленный диск). The specified path is not found or is invalid (for example, it is on an unmapped drive).

Комментарии

Возвращаемые имена файлов добавляются к указанному path параметру, а порядок возвращаемых имен файлов не гарантируется; используйте метод, Sort Если требуется конкретный порядок сортировки. The returned file names are appended to the supplied path parameter and the order of the returned file names is not guaranteed; use the Sort method if a specific sort order is required.

searchPattern может быть сочетанием литеральных символов и подстановочных знаков, но не поддерживает регулярные выражения. searchPattern can be a combination of literal and wildcard characters, but it doesn’t support regular expressions. В могут быть использованы следующие подстановочные знаки searchPattern . The following wildcard specifiers are permitted in searchPattern .

Спецификатор подстановочного знака Wildcard specifier Соответствует Matches
* * * (asterisk) Ноль или более символов в этой должности. Zero or more characters in that position.
? ? (вопросительный знак) (question mark) Ноль или один символ в этой позиции. Zero or one character in that position.

Символы, отличные от подстановочных знаков, являются литеральными символами. Characters other than the wildcard are literal characters. Например, searchPattern строка « * t» ищет все имена в path конце буквы «t». For example, the searchPattern string «*t» searches for all names in path ending with the letter «t». searchPattern Строка «s * » ищет все имена в path начале с буквой «s». The searchPattern string «s*» searches for all names in path beginning with the letter «s».

searchPattern не может заканчиваться двумя точками («..») или содержать две точки («..»), за которыми следует DirectorySeparatorChar или AltDirectorySeparatorChar , и не может содержать недопустимые символы. searchPattern cannot end in two periods («..») or contain two periods («..») followed by DirectorySeparatorChar or AltDirectorySeparatorChar, nor can it contain any invalid characters. Вы можете запросить недопустимые символы с помощью метода GetInvalidPathChars. You can query for invalid characters by using the GetInvalidPathChars method.

При использовании символа-шаблона звездочки в searchPattern таком формате, как * . txt, число символов в указанном расширении влияет на поиск следующим образом: When you use the asterisk wildcard character in a searchPattern such as «*.txt», the number of characters in the specified extension affects the search as follows:

  • Если указанное расширение имеет длину ровно три символа, метод возвращает файлы с расширениями, которые начинаются с указанного расширения. If the specified extension is exactly three characters long, the method returns files with extensions that begin with the specified extension. Например, » * . xls» возвращает «book.xls» и «book.xlsx». For example, «*.xls» returns both «book.xls» and «book.xlsx».
  • Во всех остальных случаях метод возвращает файлы, которые точно соответствуют указанному расширению. In all other cases, the method returns files that exactly match the specified extension. Например, » * . AI» возвращает «File.AI», но не «File. AIF». For example, «*.ai» returns «file.ai» but not «file.aif».

Если используется символ-шаблон вопросительного знака, этот метод возвращает только файлы, соответствующие указанному расширению файла. When you use the question mark wildcard character, this method returns only files that match the specified file extension. Например, при наличии двух файлов «file1.txt» и «file1.txtOther» в каталоге шаблон поиска «File?». txt «возвращает только первый файл, а шаблон поиска» file * . txt «возвращает оба файла. For example, given two files, «file1.txt» and «file1.txtother», in a directory, a search pattern of «file?.txt» returns just the first file, whereas a search pattern of «file*.txt» returns both files.

Так как этот метод проверяет имена файлов как в формате имени файла 8,3, так и в формате длинного имени файла, шаблон поиска, аналогичный » * 1 * . txt», может возвращать непредвиденные имена файлов. Because this method checks against file names with both the 8.3 file name format and the long file name format, a search pattern similar to «*1*.txt» may return unexpected file names. Например, использование шаблона поиска » * 1 * . txt» возвращает «longfilename.txt», так как формат имени файла эквивалентной 8,3 — «лонгфи

1.TXT». For example, using a search pattern of «*1*.txt» returns «longfilename.txt» because the equivalent 8.3 file name format is «LONGFI

EnumerateFilesМетоды и GetFiles отличаются следующим образом: при использовании EnumerateFiles можно начать перечисление коллекции имен перед возвратом всей коллекции; при использовании GetFiles необходимо дождаться возвращения всего массива имен, прежде чем можно будет получить доступ к массиву. The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array. Поэтому при работе с множеством файлов и каталогов EnumerateFiles может быть более эффективным. Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.

path Параметр может указывать сведения относительного или абсолютного пути. The path parameter can specify relative or absolute path information. Сведения об относительном пути интерпретируется как относительно текущего рабочего каталога. Relative path information is interpreted as relative to the current working directory. Сведения о получении текущего рабочего каталога см. в разделе GetCurrentDirectory . To obtain the current working directory, see GetCurrentDirectory.

path Параметр не учитывает регистр. The path parameter is not case-sensitive.

Список общих задач ввода-вывода см. в разделе Общие задачи ввода-вывода. For a list of common I/O tasks, see Common I/O Tasks.

Применяется к

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.

Параметры

Относительный или абсолютный путь к каталогу для поиска. The relative or absolute path to the directory to search. В этой строке не учитывается регистр знаков. This string is not case-sensitive.

Строка поиска, которая должна сравниваться с именами файлов в path . The search string to match against the names of files in path . Этот параметр может содержать сочетание допустимого литерального пути и подстановочного символа (* и ?), но не поддерживает регулярные выражения. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn’t support regular expressions.

Одно из значений перечисления, определяющее, следует ли выполнять поиск только в текущем каталоге или также во всех его подкаталогах. One of the enumeration values that specifies whether the search operation should include all subdirectories or only the current directory.

Возвращаемое значение

Массив полных имен (включая пути) файлов в указанном каталоге, которые соответствуют указанному шаблону и параметру поиска, или пустой массив, если файлы не найдены. An array of the full names (including paths) for the files in the specified directory that match the specified search pattern and option, or an empty array if no files are found.

Исключения

path представляет собой строку нулевой длины, содержащую только пробелы или один или несколько недопустимых символов. path is a zero-length string, contains only white space, or contains one or more invalid characters. Вы можете запросить недопустимые символы с помощью метода GetInvalidPathChars(). You can query for invalid characters with the GetInvalidPathChars() method.

-или- -or- searchPattern не содержит допустимый шаблон. searchPattern does not contain a valid pattern.

Параметр path или searchpattern имеет значение null . path or searchpattern is null .

searchOption не является допустимым значением SearchOption. searchOption is not a valid SearchOption value.

У вызывающего объекта отсутствует необходимое разрешение. The caller does not have the required permission.

Указанный путь не найден или является недопустимым (например, ведет на несопоставленный диск). The specified path is not found or is invalid (for example, it is on an unmapped drive).

Указанный путь, имя файла или оба значения превышают максимальную длину, заданную в системе. The specified path, file name, or both exceed the system-defined maximum length.

path — это имя файла. path is a file name.

-или- -or- Произошла сетевая ошибка. A network error has occurred.

Комментарии

Возвращаемые имена файлов добавляются к указанному параметру path , а порядок возвращаемых имен файлов не гарантируется; используйте метод, Sort Если требуется конкретный порядок сортировки. The returned file names are appended to the supplied parameter path and the order of the returned file names is not guaranteed; use the Sort method if a specific sort order is required.

searchPattern может быть сочетанием литеральных символов и подстановочных знаков, но не поддерживает регулярные выражения. searchPattern can be a combination of literal and wildcard characters, but it doesn’t support regular expressions. В могут быть использованы следующие подстановочные знаки searchPattern . The following wildcard specifiers are permitted in searchPattern .

Спецификатор подстановочного знака Wildcard specifier Соответствует Matches
* * * (asterisk) Ноль или более символов в этой должности. Zero or more characters in that position.
? ? (вопросительный знак) (question mark) Ноль или один символ в этой позиции. Zero or one character in that position.

Символы, отличные от подстановочных знаков, являются литеральными символами. Characters other than the wildcard are literal characters. Например, searchPattern строка « * t» ищет все имена в path конце буквы «t». For example, the searchPattern string «*t» searches for all names in path ending with the letter «t». searchPattern Строка «s * » ищет все имена в path начале с буквой «s». The searchPattern string «s*» searches for all names in path beginning with the letter «s».

searchPattern не может заканчиваться двумя точками («..») или содержать две точки («..»), за которыми следует DirectorySeparatorChar или AltDirectorySeparatorChar , и не может содержать недопустимые символы. searchPattern cannot end in two periods («..») or contain two periods («..») followed by DirectorySeparatorChar or AltDirectorySeparatorChar, nor can it contain any invalid characters. Вы можете запросить недопустимые символы с помощью метода GetInvalidPathChars. You can query for invalid characters by using the GetInvalidPathChars method.

При использовании символа-шаблона звездочки в searchPattern таком формате, как * . txt, число символов в указанном расширении влияет на поиск следующим образом: When you use the asterisk wildcard character in a searchPattern such as «*.txt», the number of characters in the specified extension affects the search as follows:

  • Если указанное расширение имеет длину ровно три символа, метод возвращает файлы с расширениями, которые начинаются с указанного расширения. If the specified extension is exactly three characters long, the method returns files with extensions that begin with the specified extension. Например, » * . xls» возвращает «book.xls» и «book.xlsx». For example, «*.xls» returns both «book.xls» and «book.xlsx».
  • Во всех остальных случаях метод возвращает файлы, которые точно соответствуют указанному расширению. In all other cases, the method returns files that exactly match the specified extension. Например, » * . AI» возвращает «File.AI», но не «File. AIF». For example, «*.ai» returns «file.ai» but not «file.aif».

Если используется символ-шаблон вопросительного знака, этот метод возвращает только файлы, соответствующие указанному расширению файла. When you use the question mark wildcard character, this method returns only files that match the specified file extension. Например, при наличии двух файлов «file1.txt» и «file1.txtOther» в каталоге шаблон поиска «File?». txt «возвращает только первый файл, тогда как шаблон поиска» филе*. txt «возвращает оба файла. For example, given two files, «file1.txt» and «file1.txtother», in a directory, a search pattern of «file?.txt» returns just the first file, whereas a search pattern of «file*.txt» returns both files.

Так как этот метод проверяет имена файлов как в формате имени файла 8,3, так и в формате длинного имени файла, шаблон поиска, аналогичный » * 1 * . txt», может возвращать непредвиденные имена файлов. Because this method checks against file names with both the 8.3 file name format and the long file name format, a search pattern similar to «*1*.txt» may return unexpected file names. Например, использование шаблона поиска » * 1 * . txt» возвращает «longfilename.txt», так как формат имени файла эквивалентной 8,3 — «лонгфи

1.TXT». For example, using a search pattern of «*1*.txt» returns «longfilename.txt» because the equivalent 8.3 file name format is «LONGFI

EnumerateFilesМетоды и GetFiles отличаются следующим образом: при использовании EnumerateFiles можно начать перечисление коллекции имен перед возвратом всей коллекции; при использовании GetFiles необходимо дождаться возвращения всего массива имен, прежде чем можно будет получить доступ к массиву. The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array. Поэтому при работе с множеством файлов и каталогов EnumerateFiles может быть более эффективным. Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.

Имена файлов включают полный путь. The file names include the full path.

path Параметр может указывать сведения относительного или абсолютного пути. The path parameter can specify relative or absolute path information. Сведения об относительном пути интерпретируется как относительно текущего рабочего каталога. Relative path information is interpreted as relative to the current working directory. Сведения о получении текущего рабочего каталога см. в разделе GetCurrentDirectory . To obtain the current working directory, see GetCurrentDirectory.

path Параметр не учитывает регистр. The path parameter is not case-sensitive.

Список общих задач ввода-вывода см. в разделе Общие задачи ввода-вывода. For a list of common I/O tasks, see Common I/O Tasks.

Читайте также:  Слетает курсор windows 10
Оцените статью