Is there any sort of ways to actually prevent "crash" on missing images. (windows form application c#) -


So I recently started just as part of the application with full windows c # part.

My question is, are there any systematic methods to prevent the program from crashing, if there is no picture?

Currently I am creating a small program of my own, where people are likely to change the look of the application (only for images now). If a person forgets to forget to "rejoin the image", then it will still be good to work, due to lack of image the white paper is crashing.

(New to Stackerowflow, so I do not know is the right place).

Thank you for your time and hopefully it came to understand. Otherwise, I will explain it differently.

There are two ways to do this (perhaps more:)) The first one is to check that the image Exists, if you are getting an image from your hard drive

  if (file.exis (@ "c: \ img.jpg")) {// do stuff}  

On the other hand, try to use try-catch block to catch error

  try {pictureBox1.image = bitmap.framefile};: ("\ img.jpg C "@)} Hold (Exception Pre) {Message Box. Show (ex.ToString ()); }  

Perhaps other ways you can do this but I think these are the easiest of them.


Comments