I'm trying something similar to recreating it on the server only I keep getting 'A generic error occurred in GDI+.' error message. I'm able to get it saved to the server but I can't open the file to convert the file type. Here is the code I have when I change
the file type. Also, after I open an image on a Clients PC is there a way to preview the image w/o putting the code into a button?
strFileName = Image1.ImageUrl()
strFileName = Path.GetFileName(strFileName)
strFolder = "C:\inetpub\wwwroot\MeetingsConventions\Borders\" & strFileName
' Open the file on the server and convert to bMP
Dim newBitmap As Bitmap = New Bitmap(strFolder)
strFilePath = strFolder & txtSaveAs.Text ' & ".bmp"
newBitmap.Save(Server.MapPath(strFilePath), ImageFormat.Bmp)
newBitmap.Dispose()
I've figured out my second question as for the first part I've included rest of the code.
strFileName = oFile.PostedFile.FileName
strFileName = Path.GetFileName(strFileName)
strFolder = "C:\.....\Borders\" & strFileName
Dim s As Stream = oFile.PostedFile.InputStream
Dim data(oFile.PostedFile.ContentLength - 1) As Byte
s.Read(data, 0, oFile.PostedFile.ContentLength)
' Create file on the server
Dim fs As System.IO.FileStream = New System.IO.FileStream(strFolder, System.IO.FileMode.Create, System.IO.FileAccess.Write)
fs.Write(data, 0, oFile.PostedFile.ContentLength - 1)
fs.Close()
s.Close()
' Open the file on the server and convert to bmp.
Dim newBitmap As Bitmap = New Bitmap(strFolder)
strFilePath = "C:\.....\Borders\" & txtSaveAs.Text & ".bmp"
newBitmap.Save(Server.MapPath(strFilePath), ImageFormat.Bmp)
newBitmap.Dispose()
chicdog
Member
115 Points
23 Posts
A generic error occurred in GDI+.
Feb 10, 2004 03:06 PM|LINK
strFileName = Image1.ImageUrl() strFileName = Path.GetFileName(strFileName) strFolder = "C:\inetpub\wwwroot\MeetingsConventions\Borders\" & strFileName ' Open the file on the server and convert to bMP Dim newBitmap As Bitmap = New Bitmap(strFolder) strFilePath = strFolder & txtSaveAs.Text ' & ".bmp" newBitmap.Save(Server.MapPath(strFilePath), ImageFormat.Bmp) newBitmap.Dispose()chicdog
Member
115 Points
23 Posts
Re: A generic error occurred in GDI+.
Feb 10, 2004 06:29 PM|LINK
strFileName = oFile.PostedFile.FileName strFileName = Path.GetFileName(strFileName) strFolder = "C:\.....\Borders\" & strFileName Dim s As Stream = oFile.PostedFile.InputStream Dim data(oFile.PostedFile.ContentLength - 1) As Byte s.Read(data, 0, oFile.PostedFile.ContentLength) ' Create file on the server Dim fs As System.IO.FileStream = New System.IO.FileStream(strFolder, System.IO.FileMode.Create, System.IO.FileAccess.Write) fs.Write(data, 0, oFile.PostedFile.ContentLength - 1) fs.Close() s.Close() ' Open the file on the server and convert to bmp. Dim newBitmap As Bitmap = New Bitmap(strFolder) strFilePath = "C:\.....\Borders\" & txtSaveAs.Text & ".bmp" newBitmap.Save(Server.MapPath(strFilePath), ImageFormat.Bmp) newBitmap.Dispose()MrDave
Participant
877 Points
177 Posts
MVP
Re: A generic error occurred in GDI+.
Feb 11, 2004 03:30 AM|LINK
Read my blog http://blog.davidyack.com
New Silverlight 3 Book - http://www.silverlightjumpstart.com
chicdog
Member
115 Points
23 Posts
Re: A generic error occurred in GDI+.
Feb 12, 2004 12:07 PM|LINK