
怎样在VS中用代码删除电脑上的文件,我想用C#写一个代码,执行命令时删除特定的文件(如图片)
展开全部
要using System.IO;然后
string path="文件路径";
if(File.Exists(path))
try{
File.Delete(path);
}
catch(Expection ex)
{
MessageBox.Show(ex.tostring);
}
string path="文件路径";
if(File.Exists(path))
try{
File.Delete(path);
}
catch(Expection ex)
{
MessageBox.Show(ex.tostring);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询