c# - Check if the image resource is null -


i working on windows phone 8 application.

string image = "/mydata/" + myobject.imagename + "big.png"; bitmapimage bmp = new bitmapimage(new uri(image , urikind.relative));                  myimage.source = bmp; 

i have image in folder mydata/, have 2 sets of images <imagename>big.png,<imagename>small.png.

so here happening want check if <imagename>big.png exists in location or not, if not pick <imagename>small.png.

how ?

edit

i solved myself, here how.

file.exists("path file") here path should `foldername/filenames` , not `/foldername/filenames` 

thanks helped me.

string image = "/mydata/" + myobject.imagename + "/big.png"; string filename = path.getfilename(image); if(!string.isnullorempty(filename)) {  messagebox.show("file exist -"+filename);  }  else  { messagebox.show("no file exist -"); } bitmapimage bmp = new bitmapimage(new uri(image , urikind.relative)); if(bmp==null)  {  image = "/mydata/" + myobject.imagename + "/small.png"; bmp = new bitmapimage(new uri(image , urikind.relative)); } myimage.source = bmp; 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -