I want to get the file size before uploading to server. I used following code
Dim fileDetails As IO.FileInfo
fileDetails = My.Computer.FileSystem.GetFileInfo(fil
The code you have implemented works only for server side objects. If you want to check the file size before allowing an upload, you would have to have an activeX control that was allowed access to the client's local file system. The best way to do this is to allow the upload and then dump unwanted files (with an error message indicating the problem). Here is how you would check the file size of an uploaded file though:
And in the code behind:
Dim fileSize as Int64 = uploadFile.PostedFile.ContentLength
At this point if the file is too big, you can just do nothing with it, and send a message back to the user to let them know it wasn't saved.