[英]How to get the path to a folder in my project (and paths to files in that folder)?
In my project, I added a folder with files in it. 在我的项目中,我添加了一个包含文件的文件夹。 They all have a local path. 他们都有一条本地路径。
I want to have a string array with all the paths to all of those files, but I have no clue how to do that. 我想要一个包含所有这些文件的所有路径的字符串数组,但是我不知道如何执行此操作。
I tried this, but it only returns strings in the format of "namespace+project+foldername+name". 我试过了,但是它只返回“名称空间+项目+文件夹名称+名称”格式的字符串。
string[] test = Assembly.GetExecutingAssembly().GetManifestResourceNames();
What I want is the full path: 我想要的是完整的路径:
D:\\Projectname\\Project\\Folder\\file.ext d:\\项目名\\项目\\文件夹\\ file.ext
It would also help to get the reference/path to the folder, because then I could get the files with: 获取文件夹的引用/路径也将有所帮助,因为这样我就可以通过以下方式获取文件:
System.IO.Directory.GetFiles();
Anyone got an idea? 有人知道吗?
尝试这个。
string path= Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()));
try this 尝试这个
string[] files= Directory.GetFiles(@"directory");
and if you want to get your project directory use 如果您想获取项目目录,请使用
string path = Directory.GetCurrentDirectory();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.