if (!File.Exists("SomeFile.exe"))
{
//Does not exists
}
Run Code Online (Sandbox Code Playgroud)
我有SomeFile.exe与exe相同的路径,但结果是不存在.
在Windows窗体中不会发生这种情况,是否会发生变化?
尝试此操作以获取可执行文件目录中的文件.
string directory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
string filePath = Path.Combine(directory, "SomeFile.exe");
if (!File.Exists(filePath))
{
// 1337 code here plx.
}
Run Code Online (Sandbox Code Playgroud)