无法在位图路径参数中引用 jpg
Unable to refer to jpg in bitmap path parameter
我的项目文件夹中有一张 jpg。我想用它制作位图,但是当我尝试引用 jpg 时它说我的路径无效。
https://i.stack.imgur.com/dAWIG.jpg
控制台异常:
Unhandled Exception: System.ArgumentException: Illegal characters in path.
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.Path.GetFullPath(String path)
at System.Drawing.IntSecurity.UnsafeGetFullPath(String fileName)
at System.Drawing.IntSecurity.DemandReadFileIO(String fileName)
at System.Drawing.Bitmap..ctor(String filename)
at ConsoleImageCompare.Compare.differance(String img1, String img2) in c:\users\user\documents\visual studio 2017\Projects\ConsoleImageCompare\ConsoleImageCompare\Compare.cs:line 22
at ConsoleImageCompare.Program.Main(String[] args)
原因是控制台应用程序默认指向 bin/debug folder.So 您需要上两层才能获取文件
@"../../image/<Your File name>"
使用这个
我的项目文件夹中有一张 jpg。我想用它制作位图,但是当我尝试引用 jpg 时它说我的路径无效。
https://i.stack.imgur.com/dAWIG.jpg
控制台异常:
Unhandled Exception: System.ArgumentException: Illegal characters in path.
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.Path.GetFullPath(String path)
at System.Drawing.IntSecurity.UnsafeGetFullPath(String fileName)
at System.Drawing.IntSecurity.DemandReadFileIO(String fileName)
at System.Drawing.Bitmap..ctor(String filename)
at ConsoleImageCompare.Compare.differance(String img1, String img2) in c:\users\user\documents\visual studio 2017\Projects\ConsoleImageCompare\ConsoleImageCompare\Compare.cs:line 22
at ConsoleImageCompare.Program.Main(String[] args)
原因是控制台应用程序默认指向 bin/debug folder.So 您需要上两层才能获取文件
@"../../image/<Your File name>"
使用这个