system.ComponentModel.Win32Exception (0x80004005): 目錄名無效。 解決方法


有時候我們需要在程序中調用 cmd.exe  執行一些命令  

比如 我們會在程序寫到

  /// <summary>
        /// 執行Cmd命令
        /// </summary>
        /// <param name="workingDirectory">要啟動的進程的目錄</param>
        /// <param name="command">要執行的命令</param>
        private void StartCmd(String workingDirectory, String command)
        {
            Process p = new Process();
            p.StartInfo.FileName = "cmd.exe";
            p.StartInfo.WorkingDirectory = workingDirectory;
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.CreateNoWindow = true;
            p.Start();
            p.StandardInput.WriteLine(command);
            //p.StandardInput.WriteLine("exit");
        }

代碼是一點問題都沒有的。你在本地調試也沒有問題。

可是就是一放到服務器上。就可能出現  system.ComponentModel.Win32Exception (0x80004005): 目錄名無效。 解決方法

在服務器中將你代碼中要調用的的

workingDirectory 目錄  的internet來賓賬戶設置為完全控制即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM