JB.
JB.

Reputation: 21

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

When I try to show an image on linklabel click, I get an error: unrecognized escape sequence.

Code:

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

}

Upvotes: 0

Views: 485

Answers (1)

kristian
kristian

Reputation: 23049

You need to escape the \ chararacters in your string (the image path) by either escaping them with another \ or using a verbatim string.

escape characters:

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

verbatim string literal:

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

Upvotes: 1

Related Questions