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

C#

 
GeneralRe: I'm Baffled Again Pin
DaveyM693-Jan-10 0:18
professionalDaveyM693-Jan-10 0:18 
GeneralRe: I'm Baffled Again Pin
Rob Philpott3-Jan-10 0:33
Rob Philpott3-Jan-10 0:33 
GeneralRe: I'm Baffled Again Pin
Richard MacCutchan3-Jan-10 4:49
mveRichard MacCutchan3-Jan-10 4:49 
GeneralRe: I'm Baffled Again Pin
Roger Wright3-Jan-10 5:40
professionalRoger Wright3-Jan-10 5:40 
GeneralRe: I'm Baffled Again Pin
Roger Wright4-Jan-10 2:15
professionalRoger Wright4-Jan-10 2:15 
GeneralRe: I'm Baffled Again Pin
DaveyM694-Jan-10 7:43
professionalDaveyM694-Jan-10 7:43 
GeneralRe: I'm Baffled Again Pin
Roger Wright4-Jan-10 13:04
professionalRoger Wright4-Jan-10 13:04 
QuestionSystem.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Image.Save Pin
uglyeyes2-Jan-10 13:34
uglyeyes2-Jan-10 13:34 
Hi,

I am trying to upload an image and resize it. the image being uploaded will be saved in photos and thumbs directory. I have given network service and iusr_machinename write access to both folders. the upload works fine in local machine its just when i try to upload via a remote server i get error "A generic error occurred in GDI+."

below are my codes for upload click event. please help

try
                {
                    String file = "";
                    String thumb = "";
                    if (flUpload.PostedFile.ContentLength > 0)
                    {
                        file = flUpload.FileName;
                        thumb = "";
                        String[] strNew = file.Split('.');
                        strNew[0] = DateTime.Now.Ticks.ToString();
                        file = strNew[0] + "." + strNew[1];
                        thumb = strNew[0] + "_t." + strNew[1];

                        ImageName = file;
                        ImagePath = Server.MapPath("~/photos") +"\\"+ ImageName;
                        Response.Write(ImagePath);

                        ImageThumbName = thumb;
                        ImageThumbPath = Server.MapPath("~/thumbs") + "\\" + ImageThumbName;
                        Response.Write(ImageThumbPath);

                       
                        using (System.Drawing.Image Img = new Bitmap(flUpload.FileContent))
                        {
                            Size ThumbNailSize = NewImageSize(Img.Height, Img.Width, 100);
                            Size ImageSize = NewImageSize(Img.Height, Img.Width, 500);

                            using (System.Drawing.Image ImgThnail = new Bitmap(Img, ThumbNailSize.Width, ThumbNailSize.Height))
                            {
                                ImgThnail.Save(ImageThumbPath, Img.RawFormat);
                                ImgThnail.Dispose();
                            }
                            using (System.Drawing.Image Img1 = new Bitmap(Img, ImageSize.Width, ImageSize.Height))
                            {
                                Img1.Save(ImagePath, Img.RawFormat);
                                Img1.Dispose();
                            }
                            Img.Dispose();
                        }
                    }
  public Size NewImageSize(int OriginalHeight, int OriginalWidth, double FormatSize)
        {
            Size NewSize; double tempval;

            if (OriginalHeight > FormatSize && OriginalWidth > FormatSize)
            {
                if (OriginalHeight > OriginalWidth)
                    tempval = FormatSize / Convert.ToDouble(OriginalHeight);
                else
                    tempval = FormatSize / Convert.ToDouble(OriginalWidth);

                NewSize = new Size(Convert.ToInt32(tempval * OriginalWidth), Convert.ToInt32(tempval * OriginalHeight));
            }
            else
                NewSize = new Size(OriginalWidth, OriginalHeight); return NewSize;
        }

AnswerRe: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Image.Save Pin
Abhinav S2-Jan-10 18:11
Abhinav S2-Jan-10 18:11 
GeneralRe: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Image.Save Pin
uglyeyes3-Jan-10 1:15
uglyeyes3-Jan-10 1:15 
GeneralRe: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Image.Save Pin
uglyeyes4-Jan-10 1:41
uglyeyes4-Jan-10 1:41 
QuestionBest way to populate this DataGridView Pin
BDJones2-Jan-10 6:50
BDJones2-Jan-10 6:50 
AnswerMessage Closed Pin
2-Jan-10 14:58
stancrm2-Jan-10 14:58 
QuestionRe: Best way to populate this DataGridView [modified] Pin
BDJones3-Jan-10 5:27
BDJones3-Jan-10 5:27 
AnswerRe: Best way to populate this DataGridView Pin
darkelv2-Jan-10 15:52
darkelv2-Jan-10 15:52 
QuestionWhy database.mdf is not filtered in a crystal report while connectiong a database? Pin
CoderForEver2-Jan-10 6:18
CoderForEver2-Jan-10 6:18 
Questionc# sockets [modified] Pin
ikurtz2-Jan-10 5:30
ikurtz2-Jan-10 5:30 
AnswerRe: c# sockets Pin
N a v a n e e t h2-Jan-10 6:48
N a v a n e e t h2-Jan-10 6:48 
AnswerRe: c# sockets Pin
Rob Philpott2-Jan-10 6:58
Rob Philpott2-Jan-10 6:58 
QuestionArithmetic operation resulted in an overflow. Pin
3bood.ghzawi2-Jan-10 3:12
3bood.ghzawi2-Jan-10 3:12 
AnswerRe: Arithmetic operation resulted in an overflow. Pin
#realJSOP2-Jan-10 3:39
mve#realJSOP2-Jan-10 3:39 
AnswerRe: Arithmetic operation resulted in an overflow. Pin
Alan N2-Jan-10 3:54
Alan N2-Jan-10 3:54 
GeneralRe: Arithmetic operation resulted in an overflow. Pin
Daniel Grunwald2-Jan-10 10:53
Daniel Grunwald2-Jan-10 10:53 
GeneralRe: Arithmetic operation resulted in an overflow. Pin
harold aptroot2-Jan-10 10:56
harold aptroot2-Jan-10 10:56 
GeneralRe: Arithmetic operation resulted in an overflow. Pin
Daniel Grunwald2-Jan-10 10:58
Daniel Grunwald2-Jan-10 10: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.