1

こんにちは frnds 誰でもこの問題を解決するのを手伝ってもらえますか? 私は .net の世界に
慣れていないので.

「GDI+ で一般的なエラーが発生しました。」

if (FileUpload2.PostedFile.ContentType == "image/pjpeg" || FileUpload2.PostedFile.ContentType == "image/jpg" || FileUpload2.PostedFile.ContentType == "image/gif" || FileUpload2.PostedFile.ContentType == "image/jpeg" || FileUpload2.PostedFile.ContentType == "image/png")
            {

            string filename = FileUpload2.FileName;


            // Specify a upload directory
            string directory = Server.MapPath(@"datalistimg\");


            // Create a bitmap in memory of the content of the fileUpload control
            Bitmap originalBMP = new Bitmap(FileUpload2.FileContent);


            // Calculate the new image dimensions
            int origWidth = originalBMP.Width;
            int origHeight = originalBMP.Height;
            int sngRatio = origWidth / origHeight;
            int newWidth = 218;
            int newHeight = (newWidth * origHeight) / origWidth;


            // Create a new bitmap which will hold the previous resized bitmap
            Bitmap newBMP = new Bitmap(originalBMP, newWidth, newHeight);


            // Create a graphic based on the new bitmap
            Graphics oGraphics = Graphics.FromImage(newBMP);


            // Set the properties for the new graphic file
            oGraphics.SmoothingMode = SmoothingMode.AntiAlias;
            oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;


            // Draw the new graphic based on the resized bitmap
            oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight);


            // Save the new graphic file to the server
            newBMP.Save(directory + filename);
            dfn2 = @"datalistimg/" + filename;


            originalBMP = null;
            newBMP = null;
            oGraphics = null;



            fn2 = System.IO.Path.GetFileName(FileUpload2.PostedFile.FileName);
            string SaveLocation = Server.MapPath("event") + "\\" + fn2;
            fn2 = "event/" + fn2;
            FileUpload2.PostedFile.SaveAs(SaveLocation);
4

0 に答える 0