[問題] Process與Unicode
各位版友好,
小弟最近在寫一隻壓縮程式,主要是遞迴處理各資料夾內的檔案壓縮,
不過壓到一半發現有些目錄的壓縮檔並未正常的產生,
後來發現是檔名有unicode的問題,
不過小弟直接將argu內的參數整串在cmd中執行是正常的,
想請問是否有辦法留下執行時的視窗,或者有其他能debug的建議。
PS:小弟也試過Process.RedirectStandardOutput()的方法,
不過log檔內只有出現winRar的訊息,
沒有加入壓縮檔的訊息。
Process 呼叫 winrar 程式段如下:
ProcessStartInfo psi =
new ProcessStartInfo(@"c:\program files\winrar\rar.exe");
string argu = @"a -m0 -rr5% ";
string rarName = "畑"; //目前測到這個字有問題
argu += "\"..\\" + rarName + ".rar\""; //將rar檔放到上一層目錄中
psi.Arguments =
Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(argu));
//這邊試過各種Encoding都無效
Process p = new Process();
p.StartInfo = psi;
try
{
p.Start();
p.WaitForExit();
p.Close();
}
catch (Exception ex) //沒有exception跳出
{
MessageBox.Show(ex.Message);
throw;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.162.188.19
→
04/23 10:13, , 1F
04/23 10:13, 1F
→
04/23 10:13, , 2F
04/23 10:13, 2F
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章
105
152