爲什麼不將測試文件夾中的文件刪除?我如何獲得管理權限?需要使用c#刪除程序文件中的文件,文件將不會刪除
namespace Delete
{
using System;
using System.Windows.Forms;
using System.IO;
public class Delete
{
public Delete()
{
if (Directory.Exists(@"C:\Program Files (x86)\test\"))
{
string[] filePaths = Directory.GetFiles(@"C:\Program Files (x86)\test\");
foreach (string file in filePaths) { File.Delete(file); }
}
}
}
}
運行它。 – vcsjones 2012-04-24 18:33:02
好吧,這將被注入到一個程序,從一個EXE運行,生病得看看你的說法,EXE將不得不作爲管理員運行,然後否? – jitsuin 2012-04-24 18:37:43