Click here to Skip to main content
14,642,320 members
Home » Discussions » C#
   

C#

 
Questionaccessing hardware information Pin
Seyyed Hossein Hasan Pour27-Jul-08 2:18
MemberSeyyed Hossein Hasan Pour27-Jul-08 2:18 
AnswerRe: accessing hardware information Pin
half-life27-Jul-08 5:58
Memberhalf-life27-Jul-08 5:58 
QuestionConvert Mp3 to Wave Files Pin
SHINOJK27-Jul-08 1:25
MemberSHINOJK27-Jul-08 1:25 
AnswerRe: Convert Mp3 to Wave Files Pin
Ian Uy27-Jul-08 3:21
MemberIan Uy27-Jul-08 3:21 
QuestionInitializing Byte Array, IndexOutOfRange Exception Pin
Ian Uy27-Jul-08 0:05
MemberIan Uy27-Jul-08 0:05 
AnswerRe: Initializing Byte Array, IndexOutOfRange Exception Pin
Guffa27-Jul-08 2:54
MemberGuffa27-Jul-08 2:54 
Questionredirecting page to another page Pin
scottichrosaviakosmos26-Jul-08 23:57
Memberscottichrosaviakosmos26-Jul-08 23:57 
QuestionA generic error occurred in GDI+ [modified] Pin
Rob Manderson26-Jul-08 23:41
protectorRob Manderson26-Jul-08 23:41 
Well, this one has me stumped.

VS2008 Targetting .NET 3.5 (error also occurs when targetting .NET 2.0)

Given the following code:

private void OnBrowse(object sender, EventArgs e)
{
    var fd = new OpenFileDialog
        {
            Filter = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*",
            Multiselect = false
        };

        if (fd.ShowDialog() == DialogResult.OK)
            pictureBox1.Load(fd.FileName);
}

in a very simple WinForms app. The code loads and displays an image in the picture box control. So I know that part is working.

The following code:

private void OnSave(object sender, EventArgs e)
{
    try
    {
        pictureBox1.Image.Save(@"c:\src\test\image.bmp", ImageFormat.Bmp);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
}

throws an 'A generic error occurred in GDI+' exception. The image file loaded in the OnBrowse handler is not the same image file I'm trying to save to. The target directory has read and write permissions. The output file is created when I run the program but has a length of zero bytes.

I've searched Google and all the solutions indicate a permissions error, which would make sense if the file isn't even created but, as it is created, I can't see it being a permission problem.

Any hints would be gratefully received.

Rob Manderson

My bloghttp://robmanderson.blogspot.com[^]

modified on Sunday, July 27, 2008 5:55 AM

AnswerRe: A generic error occurred in GDI+ Pin
Luc Pattyn27-Jul-08 1:08
sitebuilderLuc Pattyn27-Jul-08 1:08 
GeneralRe: A generic error occurred in GDI+ Pin
Rob Manderson27-Jul-08 8:08
protectorRob Manderson27-Jul-08 8:08 
GeneralRe: A generic error occurred in GDI+ Pin
Luc Pattyn27-Jul-08 8:18
sitebuilderLuc Pattyn27-Jul-08 8:18 
QuestionC# code for optimal path, given adjacency matrix/cost values? Pin
sherifffruitfly26-Jul-08 18:51
Membersherifffruitfly26-Jul-08 18:51 
AnswerRe: C# code for optimal path, given adjacency matrix/cost values? Pin
Paul Conrad26-Jul-08 19:41
professionalPaul Conrad26-Jul-08 19:41 
AnswerRe: C# code for optimal path, given adjacency matrix/cost values? Pin
Robert.C.Cartaino27-Jul-08 6:14
MemberRobert.C.Cartaino27-Jul-08 6:14 
QuestionDays until next birthday Pin
DFlat4Now26-Jul-08 16:59
MemberDFlat4Now26-Jul-08 16:59 
AnswerRe: Days until next birthday Pin
Reza Raad26-Jul-08 17:36
MemberReza Raad26-Jul-08 17:36 
GeneralRe: Days until next birthday Pin
DFlat4Now26-Jul-08 18:31
MemberDFlat4Now26-Jul-08 18:31 
QuestionRe: Days until next birthday Pin
DFlat4Now26-Jul-08 18:55
MemberDFlat4Now26-Jul-08 18:55 
AnswerRe: Days until next birthday Pin
Paul Conrad26-Jul-08 19:52
professionalPaul Conrad26-Jul-08 19:52 
AnswerRe: Days until next birthday Pin
Reza Raad26-Jul-08 21:43
MemberReza Raad26-Jul-08 21:43 
AnswerRe: Days until next birthday Pin
Guffa27-Jul-08 2:59
MemberGuffa27-Jul-08 2:59 
QuestionExe Control DLL Pin
nedracix26-Jul-08 16:20
Membernedracix26-Jul-08 16:20 
AnswerRe: Exe Control DLL Pin
Paul Conrad26-Jul-08 17:55
professionalPaul Conrad26-Jul-08 17:55 
QuestionWhere is HttpUtility.HtmlDecode ? Pin
Mohammad Dayyan26-Jul-08 12:06
MemberMohammad Dayyan26-Jul-08 12:06 
AnswerRe: Where is HttpUtility.HtmlDecode ? Pin
Jacek Gajek26-Jul-08 12:22
MemberJacek Gajek26-Jul-08 12:22 

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.