【发布时间】:2012-05-05 10:39:29
【问题描述】:
为什么test文件夹里的文件不删除??我怎样才能获得管理员权限??
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); }
}
}
}
}
【问题讨论】:
-
从提升的命令提示符运行它。
-
好吧,这将被注入一个从 exe 运行的程序中,我得看看你的说法,exe 必须以管理员身份运行,然后不是?
标签: c# admin delete-file