kennyaidan
Programmer
Hi, just a quick question. I'm trying to create thumbnails from full images. The code is working fine except when it comes to actually naming the thumbnail.
The relevant parts of the code are as follows
'Get relevant details from previous form called "MyFile"
FileName.InnerHtml = MyFile.PostedFile.FileName
Dim strFileName as string = MyFile.PostedFile.FileName
FileContent.InnerHtml = MyFile.PostedFile.ContentType
FileSize.InnerHtml = MyFile.PostedFile.ContentLength
'Get the main image
Dim currentImage as System.Drawing.Image = System.Drawing.Image.FromFile(FileName.InnerHtml)
Dim thumbImage as System.Drawing.Image
'set the width and height of the new thumbnail
Dim Width as integer = 100
Dim Height as integer = 100
Dim myOutput As FileStream
'create thumbnail
thumbImage = currentImage.GetThumbnailImage(Width, Height, nothing, nothing)
myOutput = new FileStream(MapPath(strFileName), FileMode.Create, FileAccess.Write, FileShare.Write)
'save thumbnail
thumbImage.Save(myOutput, ImageFormat.Gif)
myOutput.Close()
My problem is that i want to save the files in the following format - if the main image is called example.gif, i want to save the thumbnail as example_thb.gif. However its the "MapPath(strFileName)" line of code that is the problem. It won't allow me to create a file name string similar to the following
MapPath(strFileName"_thb".gif),
I'm only a beginner asp.net programmer so any help would be grreatly appreciated
thanks
aidan
The relevant parts of the code are as follows
'Get relevant details from previous form called "MyFile"
FileName.InnerHtml = MyFile.PostedFile.FileName
Dim strFileName as string = MyFile.PostedFile.FileName
FileContent.InnerHtml = MyFile.PostedFile.ContentType
FileSize.InnerHtml = MyFile.PostedFile.ContentLength
'Get the main image
Dim currentImage as System.Drawing.Image = System.Drawing.Image.FromFile(FileName.InnerHtml)
Dim thumbImage as System.Drawing.Image
'set the width and height of the new thumbnail
Dim Width as integer = 100
Dim Height as integer = 100
Dim myOutput As FileStream
'create thumbnail
thumbImage = currentImage.GetThumbnailImage(Width, Height, nothing, nothing)
myOutput = new FileStream(MapPath(strFileName), FileMode.Create, FileAccess.Write, FileShare.Write)
'save thumbnail
thumbImage.Save(myOutput, ImageFormat.Gif)
myOutput.Close()
My problem is that i want to save the files in the following format - if the main image is called example.gif, i want to save the thumbnail as example_thb.gif. However its the "MapPath(strFileName)" line of code that is the problem. It won't allow me to create a file name string similar to the following
MapPath(strFileName"_thb".gif),
I'm only a beginner asp.net programmer so any help would be grreatly appreciated
thanks
aidan