C# 为什么会拒绝访问
MSDN copy下来的:Process myProcess = new Process();
// Get the process start information of notepad.
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(@"E:\桌面\xlMouseLocker.exe");
// Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' object.
myProcess.StartInfo = myProcessStartInfo;
// Create a notepad.
myProcess.Start();
System.Threading.Thread.Sleep(1000);
ProcessModule myProcessModule;
// Get all the modules associated with 'myProcess'.
ProcessModuleCollection myProcessModuleCollection = myProcess.Modules;
//为什么会拒绝访问
Console.WriteLine("File names of the modules associated "
+ "with 'notepad' are:");
// Display the 'FileName' of each of the modules.
for (int i = 0; i < myProcessModuleCollection.Count; i++)
{
myProcessModule = myProcessModuleCollection[i];
Console.WriteLine(myProcessModule.ModuleName + " : "
+ myProcessModule.FileName);
}
// Get the main module associated with 'myProcess'.
myProcessModule = myProcess.MainModule;
// Display the 'FileName' of the main module.
Console.WriteLine("The process's main module's FileName is: "
+ myProcessModule.FileName);
myProcess.CloseMainWindow();
如何解决 --------------------编程问答-------------------- 是否权限不够,添加权限。 --------------------编程问答-------------------- 用管理员打开vs --------------------编程问答-------------------- 服务器配置问题吧,权限问题。
参考:http://topic.csdn.net/u/20070817/09/2301d356-b816-4c4a-b1fa-a7e97399155a.html --------------------编程问答-------------------- 在那个环境下使用的
检查操作权限
Process[] process_name = Process.GetProcesses();
foreach (Process process in process_name)
{
Console.WriteLine(process.MainModule.FileName);
Console.WriteLine(Path.GetExtension(process.MainModule.FileName));
} --------------------编程问答-------------------- 如楼上所说的,是权限问题,用管理员模式启动程序,另外,有些服务器系统盘是不能访问的。 --------------------编程问答-------------------- 怎么用 管理员模式启动程序啊
process.MainModule.FileName也会提示拒绝访问
补充:.NET技术 , C#