2010-04-30 49 views
0

當我嘗試在鏈接標籤上單擊時顯示圖像時,出現錯誤:無法識別的轉義序列。當我嘗試在鏈接標籤上單擊時顯示圖像時,出現錯誤

代碼:

public void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) 
{ 
    System.Diagnostics.Process.Start(
      "mspaint~C:\Users\Joshua Banks\Desktop\Downtown_atlanta_night.jpg"); 

} 

回答

1

您需要通過要麼逃避他們與另一個\或使用逐字字符串爲了逃避你的字符串\ chararacters(圖像路徑)。

轉義字符:

System.Diagnostics.Process.Start("mspaint~C:\\Users\\Joshua Banks\\Desktop\\Downtown_atlanta_night.jpg"); 

逐字字符串:

System.Diagnostics.Process.Start(@"mspaint~C:\Users\Joshua Banks\Desktop\Downtown_atlanta_night.jpg"); 
+0

所以這樣的:System.Diagnostics.Process.Start(「@ MSPAINT〜C:\用戶\約書亞銀行\桌面\ Downtown_atlanta_night.jpg「); – 2010-04-30 00:28:55

+0

不太像那樣 - 我已經更新了我的答案,以證明我建議 – kristian 2010-04-30 00:31:30

+0

仍然在Downtown上遇到無法識別的轉義序列...使用第一種方法時! – 2010-04-30 00:33:28

相關問題