if (!File.Exists("SomeFile.exe"))
{
//Does not exists
}
我在与 exe 相同的路径中有 SomeFile.exe,但结果是不存在。
Windows 窗体中不会发生这种情况,有什么变化吗?
最佳答案
试试这个来获取可执行文件目录中的文件。
string directory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
string filePath = Path.Combine(directory, "SomeFile.exe");
if (!File.Exists(filePath))
{
// 1337 code here plx.
}
关于c# - 文件存在于 WPF 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1356427/