Click here to Skip to main content
15,920,503 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How do I get a custom context menu to show up??? Pin
thebiostyle4-Sep-10 7:53
thebiostyle4-Sep-10 7:53 
QuestionAn easy way to archive many files into one file? [Solved] Pin
Pamodh22-Aug-10 6:28
Pamodh22-Aug-10 6:28 
AnswerRe: An easy way to archive many files into one file? Pin
Eddy Vluggen22-Aug-10 9:57
professionalEddy Vluggen22-Aug-10 9:57 
GeneralRe: An easy way to archive many files into one file? Pin
Pamodh23-Aug-10 5:34
Pamodh23-Aug-10 5:34 
GeneralRe: An easy way to archive many files into one file? Pin
Eddy Vluggen23-Aug-10 9:40
professionalEddy Vluggen23-Aug-10 9:40 
GeneralRe: An easy way to archive many files into one file? Pin
Pamodh24-Aug-10 1:47
Pamodh24-Aug-10 1:47 
QuestionProblem in saving image to database from picturebox. VB.Net 2008. Framework 3.5. Pin
priyamtheone20-Aug-10 3:23
priyamtheone20-Aug-10 3:23 
AnswerRe: Problem in saving image to database from picturebox. VB.Net 2008. Framework 3.5. Pin
Luc Pattyn20-Aug-10 3:42
sitebuilderLuc Pattyn20-Aug-10 3:42 
Hi,

first of all, congrats on a great post. This is how it should be done!

second, it is unfortunate however almost all problems inside GDI/GDI+ cause the same error message to appear and Image.Save() can fail for a whole lot of reasons (access denied, disk full, you name it).

I didn't quite follow all the possible sequences of your logic, however this would be my best guess:
- the file you want to save to is "in use";
- probably because you did open it for creating an Image object, either directly, as in Image.FromFile(); or indirectly as in new Stream(...) and Image.FromStream(). The file would be locked until the image object gets disposed of.
- there isn't really a way to free the file while you still need the image, the Image class needs access to it in case you're going to manipulate the metadata.
- my typical work-around is to never just do Image.FromFile(); instead I do:
Image temp=Image.FromFile(filepath)
Bitmap bm=new Bitmap(temp)
temp.Dispose()

Disposing is what frees the file; using a "copy constructor" for a second image object breaks the connection between the remaining image and the original file.

Hope this helps.

BTW: your code is probably lacking some Dispose() calls anyway; <cod>pic.Image=Nothing is one way of potentially throwing away the last reference to an image without disposing it, causing it to linger around longer than necessary which isn't a good idea as images are rather large objects, and they often lock a file.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.


QuestionRe: Problem in saving image to database from picturebox. VB.Net 2008. Framework 3.5. Pin
priyamtheone21-Aug-10 2:30
priyamtheone21-Aug-10 2:30 
AnswerRe: Problem in saving image to database from picturebox. VB.Net 2008. Framework 3.5. Pin
Luc Pattyn21-Aug-10 10:56
sitebuilderLuc Pattyn21-Aug-10 10:56 
QuestionHow Barcode Reader Read Image Pin
Anubhava Dimri19-Aug-10 19:07
Anubhava Dimri19-Aug-10 19:07 
AnswerRe: How Barcode Reader Read Image Pin
riced19-Aug-10 22:48
riced19-Aug-10 22:48 
QuestionDatagridview Column Pin
C#Coudou18-Aug-10 20:12
C#Coudou18-Aug-10 20:12 
AnswerRe: Datagridview Column Pin
Andy_L_J19-Aug-10 20:00
Andy_L_J19-Aug-10 20:00 
Questioninstalling to older versions of Windows Pin
RyJaBy18-Aug-10 8:25
RyJaBy18-Aug-10 8:25 
AnswerRe: installing to older versions of Windows Pin
Dave Kreskowiak18-Aug-10 9:08
mveDave Kreskowiak18-Aug-10 9:08 
AnswerRe: installing to older versions of Windows Pin
Tom Deketelaere19-Aug-10 2:30
professionalTom Deketelaere19-Aug-10 2:30 
GeneralRe: installing to older versions of Windows Pin
RyJaBy19-Aug-10 2:42
RyJaBy19-Aug-10 2:42 
QuestionDetecting selected text Pin
Pasan14817-Aug-10 7:21
Pasan14817-Aug-10 7:21 
AnswerRe: Detecting selected text Pin
Dave Kreskowiak17-Aug-10 14:41
mveDave Kreskowiak17-Aug-10 14:41 
AnswerRe: Detecting selected text Pin
Tom Foswick24-Aug-10 22:45
Tom Foswick24-Aug-10 22:45 
QuestionTextBox_Leave event only fired when move mouse to other control in vb.net 2005 Pin
Andraw Tang17-Aug-10 6:19
Andraw Tang17-Aug-10 6:19 
AnswerRe: TextBox_Leave event only fired when move mouse to other control in vb.net 2005 Pin
riced17-Aug-10 7:23
riced17-Aug-10 7:23 
GeneralRe: TextBox_Leave event only fired when move mouse to other control in vb.net 2005 Pin
Andraw Tang17-Aug-10 8:12
Andraw Tang17-Aug-10 8:12 
GeneralRe: TextBox_Leave event only fired when move mouse to other control in vb.net 2005 Pin
Eddy Vluggen17-Aug-10 9:00
professionalEddy Vluggen17-Aug-10 9:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.