Bitmap bmp = new Bitmap("D:\1.jpg");
我得到的异常是:
parameter is not valid.
我该如何解决这个问题?
最佳答案
这通常是可行的,您是否使用转义字符来转义转义字符? 示例:
Bitmap bm = new Bitmap("D:\\newfolder\\1.jpg");
//Notice the \\ the second \ escapes the first
或者像这样转义:
Bitmap bm = new Bitmap(@"D:\newfolder\1.jpg");
//Notice the @ in front of the string, that means ignore the escape characters
您的原始字符串不会对此进行转义,因此会插入一个换行符 (\n
)。
关于c# - 如何在 C# 中将图像从文件路径转换为位图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43866266/