管理者として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.