[RESOLVED] how to use string parameter having spaces
Hi all
please help me to find solution
following is the function i used to show the tif images on form, My problem is if there are spaces between the image name it generates the error,
can anybody please suggest me what should i do
Code:
bool displayimage(string imgname)
{
string imgpath;
imgpath = this.textBox2.Text.Trim();
imgname = imgpath +@imgname;
Bitmap oSourceBitmap, oThumbBitmap;
oSourceBitmap = new Bitmap (imgname);
oThumbBitmap = new Bitmap (oSourceBitmap,751,355);
this.pictureBox1.Image = oThumbBitmap;
return true ;
}
Re: how to use string parameter having spaces
Maybe
oSourceBitmap = new Bitmap (imgname.Replace(" ", "_"));
Re: how to use string parameter having spaces
I just use:
pictureBox1.Image = new Bitmap(imgname)
Re: how to use string parameter having spaces
it should work fine with or without spaces in the image path. Set a breakpoint on where the image is loaded and paste the full path here, maybe there's soemthign else wrong with it (ie, a missing backslash between the folder path and the file name)
Re: how to use string parameter having spaces
yes, i think problem is somewhere else .
thanks for your reply.