简体   繁体   English

c#如何获取文件夹中的所有文件,无论其文件类型如何

[英]c# How to get all files in a folder regardless of their file type

I am trying to retrieve all the file paths in a specific folder location. 我正在尝试检索特定文件夹位置中的所有文件路径。 I use the Directory.GetFiles("path of folder containing files") method, but it only detects files of type "File", and not files such as "ATC File". 我使用Directory.GetFiles(“包含文件的文件夹路径”)方法,但它仅检测类型为“ File”的文件,而不检测诸如“ ATC File”之类的文件。 The files have no extentions. 文件没有扩展名。

Is there a way of retrieving all files regardless of their type? 有没有一种检索所有文件的方法,而不管它们的类型如何? If possible folders (of type "File Folder") should not be detected. 如果可能,不应检测到文件夹(“文件夹”类型)。

I use the following code: 我使用以下代码:

string[] filesInSelectedFolder = Directory.GetFiles(fileLocation);
string[] filePaths = Directory.GetFiles(@"c:\MyDir\", "*.bmp",
                                     SearchOption.AllDirectories);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在C#中获取文件/文件夹类型? - How to get a file/folder type in C#? 从文件夹获取所有文件并使用C#和Json .net进行序列化时找不到文件异常 - File not found exception while get all files from a folder and serialize using C# and Json .net 如何使用 c# 从 UWP 中的文件夹“C:\\Test”中获取所有文本文件? - How to get all text files from a folder "C:\Test" in UWP using c#? 查找所有文件,无论权限如何(Windows XP,C#) - Finding ALL files regardless of permissions (Windows XP, C#) 使用 C# 获取 XML 文件中具有相同标签名称的所有标签,无论级别如何 - Get all tags of the same tag name regardless of level in XML File with C# 从c#中的文件夹中复制所有类型格式文件 - copy all type format file from folder in c# 我们如何使用Windows 8应用程序的C#获取文件夹中的所有文件 - How can we get all files in the Folder using C# for windows 8 Apps 获取方法的参数值,无论其数量或类型为C# - Get Values of Parameters of a Method Regardless their number or type C# C#获取XElement的所有子元素,无论它们的值如何 - C# get all children of XElement regardless of their value (C#)如何读取文件夹中的所有文件以查找特定行? - (C#) How to read all files in a folder to find specific lines?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM