簡體   English   中英

當我嘗試在linklabel單擊上顯示圖像時,出現錯誤

[英]When I try to show an image on linklabel click, I get an error

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

碼:

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");

}

您需要通過用另一個\\轉義或使用逐字字符串來轉義字符串(圖像路徑)中的\\字符。

轉義字符:

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");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM