FileStream help! :(
-
Hi, im trying to get a image from a path. foto is a string path espec. by the user.
FileStream f = new FileStream( foto, FileMode.Open ); Image img = Image.FromStream( f );
This doesnt working, its only works if the image is in the same folder of the program =/ Thanks. -
Hi, im trying to get a image from a path. foto is a string path espec. by the user.
FileStream f = new FileStream( foto, FileMode.Open ); Image img = Image.FromStream( f );
This doesnt working, its only works if the image is in the same folder of the program =/ Thanks.MoOnBoY wrote: Image.FromStream( f ); I think there is a better way! Just use:
Image img = Image.FromFile("C:\\...");
Oh, and a little correction: This doesnt working, its only works if the image is in the same folder of the program. This doesn't work. Its only working if the image is in the same folder as the program. ;););) Just kidding ;);););) Good luck! -
MoOnBoY wrote: Image.FromStream( f ); I think there is a better way! Just use:
Image img = Image.FromFile("C:\\...");
Oh, and a little correction: This doesnt working, its only works if the image is in the same folder of the program. This doesn't work. Its only working if the image is in the same folder as the program. ;););) Just kidding ;);););) Good luck! -
The path is specificated by the USER... foto is the path, if I use:
Image img = Image.FromFile( foto );
Only works if the path is the same of program folder....Let's say we have a textBox called
textBox1
. And let's say we hava a picture box calledpictureBox1
. We use pictureBox1 to view the image. The user types in the CORRECT path. The user clicks on a button. And now the button's OnClick event:Image img = Image.FromFile (this.textBox1.Text); this.pictureBox1.Image = img;
Then add an error handling with TRY and CATCH. I've already tested this code. It MUST work. -
The path is specificated by the USER... foto is the path, if I use:
Image img = Image.FromFile( foto );
Only works if the path is the same of program folder....If the path is specified by the user then use Image img = Image.FromFile ( @foto );
-
If the path is specified by the user then use Image img = Image.FromFile ( @foto );
as i understood that u ve image and u want to open it from stream file... 1-u cant use Image class as it is abstract one, so u cant define object from it 2-u use Bitmap class to open ur image //example: dont forget to use (Using System.Drawing) Bitmap myimage=new Bitmap(filestream,true); //constructor use true to make error correction..hope it works