我想以管理员身份复制 C 根目录中的文件,它适用于某些路径。我使用的用户具有管理员权限,但我仍然无法复制。
我的代码是:
string strCmdText = string.Empty;
strCmdText = "copy /Y " + "\"" + fullpath + "\"" + " " + "\"" + _name.FullPath + "\\" + subject + ".msg" + "\"";
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = "cmd.exe";
startInfo.Verb = "runas";
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
startInfo.Arguments = strCmdText;
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
process.StartInfo = startInfo;
process.Start();
StreamWriter sw = process.StandardInput;
sw.WriteLine(strCmdText);
sw.Close();
process.WaitForExit();
string output = process.StandardOutput.ReadToEnd();
process.Dispose();
process.Close();
我收到以下错误:
You don't have appropriate permission to perform this operation.