473,320 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Saving Image Problem

HI All,

I am having a problem saving the image in when using this code. The Language i am using is VB.NET 2005

Dim dlgImage As New OpenFileDialog

dlgImage.Filter = "Image Files (*.bmp, *.gif, *.jpg)|*.bmp;*.gif;*.jpg"

If dlgImage.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim fs As New StreamReader(dlgImage.FileName)
Dim img As Image = Image.FromStream(fs.BaseStream)
fs.Close()
picImage.Image = img
End If
picImage.Image.Save(dlgImage.FileName, ImageFormat.Jpeg)

Here picImage is the Picture Box, Now the problem is that it gives me a error "A generic error occured in GDI+"

Please guide on the same, it would be of great help to me as i am already running late in Project.

Thanks in Advance,

Prashant Hirapara
Jun 19 '07 #1
2 1131
kenobewan
4,871 Expert 4TB
There are a number of reasons this could happen, try moving fs.Close()
down or comment out as a first step. HTH.
Jun 19 '07 #2
There are a number of reasons this could happen, try moving fs.Close()
down or comment out as a first step. HTH.
----------------------------------------------------------------------------------------------------------------------

HI Thanks man really its working .... i really appreciate yr prompt response..

Now there is a little problem with my code there is a case where the file i am opening let say "C:\Img.jpg" the same file i want to save it with the same name e.g.

"C:\Img.jpg".

Again the same error is coming and it is telling me that file is already opened by another process.

Can u guide me what is the best way to deal with this ... i am thinking of making an temporary image and then load it from there.

Thanks Again,

Prashant Hirapara
Jun 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: mchl gdbt | last post by:
Hi, I have several thousand tiffs generated by application A which are read by application B. I need to remove a few colours from the tiffs and I decided to try with the python imaging library....
4
by: Michael Kennedy [UB] | last post by:
Hi Everyone, I have this multithreaded C# windows forms application which does a lot of image processing. Occasionally, I get the following error: A generic error occurred in GDI+....
0
by: Umesh | last post by:
Hi, I have an Application, in which 1) need to post data to a URL(Remote Server), by using HTTPRequest. 2) get the Image data in the form of Stream in Response. 3) need to save this stream as a...
2
by: Peder Y | last post by:
My code is something like this: --------------- Image img = Image.FromFile("somefile.bmp"); FileStream fStream = new FileStream("someBinaryFile.dat"); BinaryWriter bw = new...
5
by: Thaynann | last post by:
I have an app that (at the moment) moves through files that are on a web site, and deletes them, wat i want to do for the next stage, is to be able to download each file before i delete it. i...
4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
2
by: Brad | last post by:
I have code which takes an image, uploaded from a web page, and saves it to a database. Now I want to always resize an uploaded image before it is saved to the database. My code to resize is...
6
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a...
6
by: Mark Denardo | last post by:
My question is similar to one someone posted a few months back, but I don't see any replies. Basically I want to be able to have users upload photos and save them in a database (as byte data)...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.