查看图像时不支持给定路径的格式

mar*_*333 3 c# picturebox

我在从文件夹路径查看图像时遇到问题.我不知道如何解决这个问题.我试过用

我的守则

String Path = @"C:\Users\PC\Documents\Visual Studio 2012\ProjectName\image-folder\mypicture.jpg";

picturebox_view.Image = Image.FromFile("'" + Path + "'");
Run Code Online (Sandbox Code Playgroud)

我收到以下错误说

The Given Path's Format Is Not Supported...
Run Code Online (Sandbox Code Playgroud)

当我试图调试并检查我的"路径"的值时,它似乎是错误的.结果就是这样

String Path = "C:\\Users\\PC\\Documents\\Visual Studio 2012\\...";
Run Code Online (Sandbox Code Playgroud)

我尝试使用替换参数的Path2,但它似乎并没有在我的工作.

这是我的替换代码(不工作)

String Path = @"C:\Users\PC\Documents\Visual Studio 2012\ProjectName\image-folder\mypicture.jpg";

String Path2 = Path.Replace(@"\\", @"\");
picturebox_view.Image = Image.FromFile("'" + Path2 + "'");
Run Code Online (Sandbox Code Playgroud)

在此先感谢我的同事们.

SLa*_*aks 5

您将看到调试器显示C#字符串文字.该字符串实际上没有双斜杠.

你真正的问题是没有'C:驱动器.不要在路径上放置引号.