Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyPath, MyName As String
Display the names in C:\ that represent directories.
MyPath = "C:\www\tester" Set the path.
MyName = Dir(MyPath, vbDirectory) Retrieve the first entry.
If MyName = "" Then The folder is not there & to be created
MkDir("C:\www\tester") Folder created
span2.InnerHtml = "A Folder is created at the Page_Load"
End If
End Sub
Sub Upload_Click(ByVal Sender As Object, ByVal e As EventArgs)
Display properties of the uploaded file
FileName.InnerHtml = MyFile.PostedFile.FileName
FileContent.InnerHtml = MyFile.PostedFile.ContentType
FileSize.InnerHtml = MyFile.PostedFile.ContentLength
UploadDetails.visible = True
Let us recover only the file name from its fully qualified path at client
Dim strFileName As String
strFileName = MyFile.PostedFile.FileName
Dim c As String = System.IO.Path.GetFileName(strFileName) only the attched file name not its path
Let us Save uploaded file to server at C:\www\tester
Try
Dim b As Bitmap
b = b.FromStream(MyFile.PostedFile.InputStream)
Dim s As Bitmap create a new bitmap and make a thumbnail of 100 X 100 pixels
s = b.GetThumbnailImage(100, 100, New Image.GetThumbnailImageAbort(AddressOf tb), IntPtr.Zero)
s.Save("C:\www\tester\" + "TN_file.jpg")
MyFile.PostedFile.SaveAs("C:\www\tester\" + "file.jpg")
addPic(c)
Span1.InnerHtml = "Your File Uploaded Sucessfully at server as : C:\www\tester" & c & _
" -//- " & FileContent.InnerHtml & " : file content " & _
" -//- " & FileSize.InnerHtml & " : file size" & _
" -//- " & FileName.InnerHtml & " : file name"
Catch Exp As Exception
Span1.InnerHtml = Err.Number.ToString & " // " & Err.Description & _
" // " & Err.Erl.ToString & " // " & Err.Source.ToString & _
" // " & Err.GetException.ToString & " // "
UploadDetails.Visible = False
Span2.Visible = False
End Try
End Sub
Private Function tb() As Boolean
Return False
End Function