获取项目内文件夹中的文件内容



我正在尝试访问项目中的文件。

所以我会创建一个名为Files的新文件夹,并在该文件夹中包含各种HTML文件。

无论如何,我可以通过转到"Program/Files/file.html"或类似内容来访问这些文件。

你的意思是这样吗?

using System.IO;
...
string folderPath = AppDomain.CurrentDomain.BaseDirectory; // or whatever folder you want to load..
foreach (string file in Directory.EnumerateFiles(folderPath, "*.html"))
{
    string contents = File.ReadAllText(file);
}

最新更新