I have a jpg in a folder in my project. I want to make a bitmap out of it but it says my path is invalid when I try to refer to the jpg.
https://i.sstatic.net/dAWIG.jpg
Console Exception:
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)
The reason is by default console application points to the bin/debug folder.So you need to go up two level to get the file
@"../../image/<Your File name>"
Use this