I upload an image this way.

Image _img = Image.FromFile("C:/...Puzzle/Img/444.jpg"); 

When you try to upload an image without specifying the full path, exeption crashes.

 An exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll but was not handled in user code Additional information: 444.jpg 

How can I upload an image without specifying the path to it?

    1 answer 1

    You can specify a relative path. For example, regarding the main application, you can specify it as

     Image _img = Image.FromFile("..\\Puzzle\\Img\\444.jpg"); 

    This method indicates the program path to the directory which is located above the program and in which there is a Puzzle catalog.

    A living example would be:

     var applicationFolder = "C:\\ProgramFolder"; var fileName = "C:\\Puzzle\\Img\\444.jpg"; // или так, относительно программы fileName = "..\\Puzzle\\Img\\444.jpg"; 

    Either by specifying the full path, or using the system variables. Any other way will result in an error.