Asp.net System.Runtime.InteropServices.ExternalException:GDI+;中发生一般错误;。接口信息处理器

Asp.net System.Runtime.InteropServices.ExternalException:GDI+;中发生一般错误;。接口信息处理器,asp.net,Asp.net,惠…有点紧急。。。 iam使用临时文件夹存储预览图像,当我尝试将它们保存为System.Runtime.InteropServices.ExternalException时:报告GDI+erreo中发生一般错误。。。 如果FileUpload1.HasFile,则 Dim路径为字符串=Server.MapPath(“./tempmages/”) 作为新文件信息的文件名(FileUpload1.PostedFile.FileName) 这就是我所做的,也是为了拯救 如果是(FileUpload1.

惠…有点紧急。。。 iam使用临时文件夹存储预览图像,当我尝试将它们保存为System.Runtime.InteropServices.ExternalException时:报告GDI+erreo中发生一般错误。。。 如果FileUpload1.HasFile,则 Dim路径为字符串=Server.MapPath(“./tempmages/”) 作为新文件信息的文件名(FileUpload1.PostedFile.FileName)

这就是我所做的,也是为了拯救

如果是(FileUpload1.HasFile),那么 Dim strextension As String=System.IO.Path.GetExtension(FileUpload1.FileName) 如果(strextension.ToUpper()=“.JPG”),则


如果我们在本地运行它,但不是在服务器上运行,它会很好地工作。

试试这个,它对我很有用:

Dim path As String = Server.MapPath("~/TempImages")

Dim FileInfo As New IO.FileInfo(FileUpload1.PostedFile.FileName)
Dim fileName As String = FileInfo.Name


'sets the image path

Dim fullFileName As String = path + "\" + fileName
Dim imagePath As String = "TempImages/" + fileName

'If Not Directory.Exists(path) Then

If Not System.IO.Directory.Exists("directory path") Then
    System.IO.Directory.Exists("directory path")
End If

FileUpload1.PostedFile.SaveAs(fullFileName)
Image1.ImageUrl = imagePath
                Dim imagetoberezised As System.Drawing.Image = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream)
                Dim imageheight As Integer = imagetoberezised.Height
                Dim imagewidth As Integer = imagetoberezised.Width
                Dim maxheight As Integer = 120
                Dim maxwidth As Integer = 80
                imageheight = (imagewidth * maxheight) / imageheight
                imagewidth = maxheight
                If imageheight > maxheight Then
                    imageheight = (imagewidth * maxheight) / imageheight
                    imagewidth = maxheight


                End If
                Dim bitmap As New Bitmap(imagetoberezised, imagewidth, imageheight)
                Dim stream As System.IO.MemoryStream = New MemoryStream()
                bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg)
                stream.Position = 0
                Dim img As Byte() = New Byte(stream.Length) {}
                stream.Read(img, 0, img.Length)
                Dim conn5 As New SqlConnection
                conn5 = New SqlConnection
                conn5.ConnectionString = "Server=aa-pc;Database=abcc;Uid=sa;Pwd=sa@123;"
                Try
                    conn5.Open()
                    Dim sql As String = "update abcset abc_IMAGE = @eimg where PART_NO=" & Val(Part_List.SelectedValue)
                    Dim cmd5 As SqlCommand = New SqlCommand(sql, conn5)
                    Dim uploadimage As New SqlParameter("@eimg", SqlDbType.Image, img.Length)
                    uploadimage.Value = img
                    cmd5.Parameters.Add(uploadimage)
                    Dim id As Integer = Convert.ToInt32(cmd5.ExecuteScalar())




                Catch
                    MsgBox("error")

                Finally
                    conn5.Close()

                End Try

            End If
        End If
Dim path As String = Server.MapPath("~/TempImages")

Dim FileInfo As New IO.FileInfo(FileUpload1.PostedFile.FileName)
Dim fileName As String = FileInfo.Name


'sets the image path

Dim fullFileName As String = path + "\" + fileName
Dim imagePath As String = "TempImages/" + fileName

'If Not Directory.Exists(path) Then

If Not System.IO.Directory.Exists("directory path") Then
    System.IO.Directory.Exists("directory path")
End If

FileUpload1.PostedFile.SaveAs(fullFileName)
Image1.ImageUrl = imagePath