Wou*_*ens 11
if (System.IO.File.Exists("pathtofile"))
//it exist
else
//it does not exist
Run Code Online (Sandbox Code Playgroud)
在提出问题之后编辑了我的答案:
我复制了代码并更改了退出功能,这应该可行
string type = Path.GetExtension(filepath);
string path = @"image/" + type + ".png";
//if(System.IO.File.Exists(path)) I forgot to use the full path
if (System.IO.File.Exists(Path.Combine(Directory.GetCurrentDirectory(), path)))
{ return path; }
else
{ return @"image/other.png"; }
Run Code Online (Sandbox Code Playgroud)
在部署应用程序时,这确实有效
| 归档时间: |
|
| 查看次数: |
10073 次 |
| 最近记录: |