I am geting this error. I was trying do it many ways but coudnt find a solution please help me
In this code i am triying to save resized image for network folder. its works first time onece i tryto update the picture its giving "A generic error occurred in GDI+." error
Plz find the attachment
Private Function ResiszeImage(ByVal strFilepath As String, ByVal strEMPNo As String)
'At the top of your code
Dim bm As New Bitmap(strFilepath)
Dim width As Integer = PicBoxPickers.Width
Dim height As Integer = PicBoxPickers.Height
Dim thumb As New Bitmap(width, height)
Dim FilePath As String = "\\192.168.1.41\media\photo\systemphotos\"
Dim UserAccount As String = "TDL-Sanjaya"
Dim oFolderInfo As IO.DirectoryInfo = New IO.DirectoryInfo(FilePath)
Dim oFolderAcl As New DirectorySecurity(FilePath, System.Security.AccessControl.AccessControlSections.Access)
oFolderAcl.AddAccessRule(New FileSystemAccessRule(UserAccount, _
FileSystemRights.FullControl, _
AccessControlType.Allow))
oFolderInfo.SetAccessControl(oFolderAcl)
oFolderAcl = Nothing
oFolderInfo = Nothing
If Directory.Exists("\\192.168.1.41\media\photo\systemphotos\") = False Then
Call Directory.CreateDirectory("\\192.168.1.41\media\photo\systemphotos\")
End If
PicBoxPickers.Image = Nothing
Dim g As Graphics = Graphics.FromImage(thumb)
Try
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(bm, New Rectangle(0, 0, width, height), New Rectangle(0, 0, bm.Width, bm.Height), GraphicsUnit.Pixel)
g.Dispose()
bm.Dispose()
strFilepath = "\\192.168.1.41\media\photo\systemphotos\" + strEMPNo + ".jpg"
lblFilePath.Text = strFilepath
PicBoxPickers.Image = thumb
PicBoxPickers.Image.Save(strFilepath, ImageFormat.Jpeg) '
thumb.Dispose()
Return True
Catch ex As Exception
Return False
End Try
End Function
In this code i am triying to save resized image for network folder. its works first time onece i tryto update the picture its giving "A generic error occurred in GDI+." error
Plz find the attachment
Private Function ResiszeImage(ByVal strFilepath As String, ByVal strEMPNo As String)
'At the top of your code
Dim bm As New Bitmap(strFilepath)
Dim width As Integer = PicBoxPickers.Width
Dim height As Integer = PicBoxPickers.Height
Dim thumb As New Bitmap(width, height)
Dim FilePath As String = "\\192.168.1.41\media\photo\systemphotos\"
Dim UserAccount As String = "TDL-Sanjaya"
Dim oFolderInfo As IO.DirectoryInfo = New IO.DirectoryInfo(FilePath)
Dim oFolderAcl As New DirectorySecurity(FilePath, System.Security.AccessControl.AccessControlSections.Access)
oFolderAcl.AddAccessRule(New FileSystemAccessRule(UserAccount, _
FileSystemRights.FullControl, _
AccessControlType.Allow))
oFolderInfo.SetAccessControl(oFolderAcl)
oFolderAcl = Nothing
oFolderInfo = Nothing
If Directory.Exists("\\192.168.1.41\media\photo\systemphotos\") = False Then
Call Directory.CreateDirectory("\\192.168.1.41\media\photo\systemphotos\")
End If
PicBoxPickers.Image = Nothing
Dim g As Graphics = Graphics.FromImage(thumb)
Try
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(bm, New Rectangle(0, 0, width, height), New Rectangle(0, 0, bm.Width, bm.Height), GraphicsUnit.Pixel)
g.Dispose()
bm.Dispose()
strFilepath = "\\192.168.1.41\media\photo\systemphotos\" + strEMPNo + ".jpg"
lblFilePath.Text = strFilepath
PicBoxPickers.Image = thumb
PicBoxPickers.Image.Save(strFilepath, ImageFormat.Jpeg) '
thumb.Dispose()
Return True
Catch ex As Exception
Return False
End Try
End Function