Click here to Skip to main content
15,891,375 members
Home / Discussions / C#
   

C#

 
GeneralRe: Enums, Intellisense, and switchs… Pin
Dan Mos5-Mar-10 11:52
Dan Mos5-Mar-10 11:52 
GeneralRe: Enums, Intellisense, and switchs… Pin
harold aptroot5-Mar-10 11:55
harold aptroot5-Mar-10 11:55 
GeneralRe: Enums, Intellisense, and switchs… Pin
Dan Mos5-Mar-10 11:56
Dan Mos5-Mar-10 11:56 
GeneralRe: Enums, Intellisense, and switchs… Pin
Matthew Klein5-Mar-10 11:56
Matthew Klein5-Mar-10 11:56 
GeneralRe: Enums, Intellisense, and switchs… Pin
BryanWilkins5-Mar-10 11:58
professionalBryanWilkins5-Mar-10 11:58 
AnswerRe: Enums, Intellisense, and switchs… Pin
RCoate5-Mar-10 15:54
RCoate5-Mar-10 15:54 
AnswerRe: Enums, Intellisense, and switchs… Pin
#realJSOP6-Mar-10 1:06
mve#realJSOP6-Mar-10 1:06 
QuestionGDI Related issue - External Exception being thrown in System.Drawing.dll Pin
Eagle325-Mar-10 10:19
Eagle325-Mar-10 10:19 
Hi,

i am trying to write a title to an image and save it back to its current location but i am having a problem as the following message is being thrown:

A generic error occured in GDI+
A first chance exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll
System.Drawing
A first chance exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll
System.Drawing

Error code: -2147467259

" at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)\r\n
at System.Drawing.Image.Save(String filename, ImageFormat format)\r\n at ZooSystem.ImageViewer.ApplyChanges()
in E:\\ZooSystem\\\ImageViewer.cs:line 520"

I have checked the permissions for each of the images in the folder and they all have FullControl/Read/Write/Modify permissions but the folder has "Read-Only" enabled.

The folder was created on the Internal Hard drive of the computer and I am using Windows Vista Home Premium 32-bit. I am using MS VS 2008 Pro edition which i run in Admin mode.

If i save the images to another folder say one of the Public folders then the above exception is not thrown.

But I would like to save my images to the same folder if possible?

How could i go about doing this? I would appreciate if somebody could help me with the above. I have been trying to fix it for past 2 hours.

Thanks,

Here is the code i am using:

private void ApplyChanges()
{
//check if the destination folder in the textbox is blank in order to save a single image
//using the Save-file dialog feature.
if(txtBoxOut.Text.Equals("")
{
  //write the title to the image by calling a write method

  //show the save file dialog and check if result is OK.
   //call the custom save method 
    if(sfd.ShowDialog()==DialogResult.OK)
    {
        
       this.SaveTheImage(sfd.FileName,this.bmp);
    }
  
}
else if(txtBoxOut.Text != "")
{

   string destFolder = txtBoxOut.text
   foreach(string filePath in filePaths)
   {
      this.bmp = Image.FromFile(filePath);
      string fileName = Path.GetFileName(filePath);
      
     try 
     {

       //write the title to the global image

       //check folder
      if(destFolder.EndsWith("\\")
      {
        //use the inbuilt save method
        this.bmp.Save(destFolder+fileName+ImageFormat.Jpeg);
      }
      else
      {
        this.bmp.Save(destFolder+"\\"+fileName+ImageFormat.Jpeg);
        
      }

     }
     catch(Exception e)
     {

        Console.WriteLine(e.message.ToString());
     }

   }
 }
}

Answercommon problem, standard answer Pin
Luc Pattyn5-Mar-10 10:27
sitebuilderLuc Pattyn5-Mar-10 10:27 
GeneralRe: common problem, standard answer Pin
Giorgi Dalakishvili6-Mar-10 2:51
mentorGiorgi Dalakishvili6-Mar-10 2:51 
GeneralRe: common problem, standard answer Pin
Luc Pattyn6-Mar-10 5:04
sitebuilderLuc Pattyn6-Mar-10 5:04 
AnswerRe: GDI Related issue - External Exception being thrown in System.Drawing.dll Pin
BryanWilkins5-Mar-10 10:28
professionalBryanWilkins5-Mar-10 10:28 
GeneralRe: GDI Related issue - External Exception being thrown in System.Drawing.dll Pin
Eagle325-Mar-10 11:21
Eagle325-Mar-10 11:21 
AnswerRe: GDI Related issue - External Exception being thrown in System.Drawing.dll Pin
BryanWilkins5-Mar-10 11:40
professionalBryanWilkins5-Mar-10 11:40 
GeneralRe: GDI Related issue - External Exception being thrown in System.Drawing.dll Pin
Eagle325-Mar-10 12:19
Eagle325-Mar-10 12:19 
GeneralRe: GDI Related issue - External Exception being thrown in System.Drawing.dll Pin
Luc Pattyn5-Mar-10 11:48
sitebuilderLuc Pattyn5-Mar-10 11:48 
GeneralRe: GDI Related issue - External Exception being thrown in System.Drawing.dll Pin
BryanWilkins5-Mar-10 11:51
professionalBryanWilkins5-Mar-10 11:51 
GeneralRe: GDI Related issue - External Exception being thrown in System.Drawing.dll [modified] Pin
Eagle325-Mar-10 12:35
Eagle325-Mar-10 12:35 
AnswerRe: GDI Related issue - External Exception being thrown in System.Drawing.dll Pin
Luc Pattyn5-Mar-10 13:35
sitebuilderLuc Pattyn5-Mar-10 13:35 
GeneralRe: GDI Related issue - External Exception being thrown in System.Drawing.dll Pin
Eagle326-Mar-10 0:04
Eagle326-Mar-10 0:04 
GeneralRe: GDI Related issue - External Exception being thrown in System.Drawing.dll Pin
BryanWilkins6-Mar-10 3:55
professionalBryanWilkins6-Mar-10 3:55 
GeneralRe: GDI Related issue - External Exception being thrown in System.Drawing.dll Pin
Eagle3210-Mar-10 11:28
Eagle3210-Mar-10 11:28 
GeneralRe: GDI Related issue - External Exception being thrown in System.Drawing.dll Pin
BryanWilkins10-Mar-10 11:32
professionalBryanWilkins10-Mar-10 11:32 
QuestionDynamic Form Pin
eddieangel5-Mar-10 9:21
eddieangel5-Mar-10 9:21 
AnswerRe: Dynamic Form Pin
BryanWilkins5-Mar-10 9:58
professionalBryanWilkins5-Mar-10 9:58 

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.