Click here to Skip to main content
15,888,301 members
Home / Discussions / C#
   

C#

 
GeneralRe: Weird Debugging Problem Pin
Keith Barrow29-Dec-09 4:40
professionalKeith Barrow29-Dec-09 4:40 
AnswerRe: Weird Debugging Problem Pin
Saksida Bojan29-Dec-09 3:07
Saksida Bojan29-Dec-09 3:07 
GeneralRe: Weird Debugging Problem Pin
#realJSOP29-Dec-09 4:04
mve#realJSOP29-Dec-09 4:04 
GeneralRe: Weird Debugging Problem Pin
ProtoBytes29-Dec-09 8:43
ProtoBytes29-Dec-09 8:43 
Questionhow to move multipoint button at run time Pin
krunal2528-Dec-09 23:22
krunal2528-Dec-09 23:22 
AnswerRe: how to move multipoint button at run time Pin
Luc Pattyn29-Dec-09 1:11
sitebuilderLuc Pattyn29-Dec-09 1:11 
QuestionError: A Generic Error occured in GDI+ Pin
Udayaraju28-Dec-09 23:00
Udayaraju28-Dec-09 23:00 
AnswerRe: Error: A Generic Error occured in GDI+ Pin
Luc Pattyn29-Dec-09 1:15
sitebuilderLuc Pattyn29-Dec-09 1:15 
Hi,


what is that tilde doing there?

Here is a standard reply I found in the attic:

Most, if not all, errors inside GDI+ are reported as "generic problem occurred in GDI+". If the affected line is an Image.Save chances are your path is incorrect or inaccessible, your disk is full, or your destination file exists and is locked.

If you load an image from a file, most of the time the file remains locked as long as the Image is alive. This would prevent you from saving an image to the same path.

It applies to Image.FromFile, and probably also to PictureBox.ImageLocation
The one exception I am aware of is when you use Image.FromStream.

So I suggest one of these two workarounds:
Bitmap bm=null;
{
    Bitmap bm1=Image.FromFile(filepath);
    bm=new Bitmap(bm1);
    bm1.Dispose();
}
// bm is OK now, and bm1 is disposed of and out of scope, the file isn’t locked.

or
Bitmap bm=null;
using (FileStream stream=File.OpenRead("image.jpeg")) {
    bm=Image.FromStream(stream);
}


Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

Merry Christmas and a Happy New Year to all.


GeneralRe: Error: A Generic Error occured in GDI+ Pin
Ben Fair29-Dec-09 3:28
Ben Fair29-Dec-09 3:28 
AnswerRe: Error: A Generic Error occured in GDI+ Pin
Hristo-Bojilov29-Dec-09 1:24
Hristo-Bojilov29-Dec-09 1:24 
AnswerRe: Error: A Generic Error occured in GDI+ Pin
Ben Fair29-Dec-09 3:23
Ben Fair29-Dec-09 3:23 
Questionsetinputtodefaultaudiodevice() not working in xp Pin
krinaljariwala28-Dec-09 22:54
krinaljariwala28-Dec-09 22:54 
AnswerRe: setinputtodefaultaudiodevice() not working in xp Pin
#realJSOP28-Dec-09 23:58
mve#realJSOP28-Dec-09 23:58 
GeneralRe: setinputtodefaultaudiodevice() not working in xp Pin
krinaljariwala29-Dec-09 0:03
krinaljariwala29-Dec-09 0:03 
GeneralRe: setinputtodefaultaudiodevice() not working in xp Pin
#realJSOP29-Dec-09 0:14
mve#realJSOP29-Dec-09 0:14 
GeneralRe: setinputtodefaultaudiodevice() not working in xp Pin
krinaljariwala29-Dec-09 0:17
krinaljariwala29-Dec-09 0:17 
AnswerRe: setinputtodefaultaudiodevice() not working in xp Pin
#realJSOP29-Dec-09 0:21
mve#realJSOP29-Dec-09 0:21 
GeneralRe: setinputtodefaultaudiodevice() not working in xp Pin
krinaljariwala29-Dec-09 0:37
krinaljariwala29-Dec-09 0:37 
AnswerRe: setinputtodefaultaudiodevice() not working in xp [modified] Pin
#realJSOP29-Dec-09 0:35
mve#realJSOP29-Dec-09 0:35 
QuestionSyncing data between SQL Server 2005 and Velocity (Distributed cache application) Pin
Gans_iitm28-Dec-09 21:03
Gans_iitm28-Dec-09 21:03 
QuestionFTP provider for windows 2008 ftp server Pin
Member 401661628-Dec-09 20:45
Member 401661628-Dec-09 20:45 
QuestionWebDAV Pin
satsumatable28-Dec-09 20:38
satsumatable28-Dec-09 20:38 
AnswerRe: WebDAV Pin
#realJSOP28-Dec-09 23:58
mve#realJSOP28-Dec-09 23:58 
QuestionWith regard to "csexwb" lost in the new tab window document.referrer Pin
590240@qq.com28-Dec-09 20:18
590240@qq.com28-Dec-09 20:18 
AnswerRe: With regard to "csexwb" lost in the new tab window document.referrer Pin
Abhinav S28-Dec-09 20:41
Abhinav S28-Dec-09 20:41 

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.