Hey there DaniWeb!
I have a bit of a problem! I am in need of a way to get the size of a remote file, without download the file itself (so that i can show download status in a status bar)
is this even possible?
Thank you a lot, Weliaz :-).
Hey there DaniWeb!
I have a bit of a problem! I am in need of a way to get the size of a remote file, without download the file itself (so that i can show download status in a status bar)
is this even possible?
Thank you a lot, Weliaz :-).
Try one of these
'http
Dim Request As System.Net.WebRequest
Dim Response As System.Net.WebResponse
Dim FileSize As Integer
Request = Net.WebRequest.Create("http://www.??")
Request.Method = Net.WebRequestMethods.Http.Get
Response = Request.GetResponse
FileSize = Response.ContentLength
'ftp
Dim FtpRequest As Net.FtpWebRequest
Dim FtpResponse As Net.FtpWebResponse
FtpRequest = Net.FtpWebRequest.Create("ftp://www.??")
FtpRequest.Method = Net.WebRequestMethods.Ftp.GetFileSize
FtpResponse = FtpRequest.GetResponse
FileSize = FtpResponse.ContentLength
Just think i will need to notice about this:
File is not gonna be downloaded before it finds file size, it shouldn't take like 2 minutes to get file size of a 200MB file.
File is gonna be downloaded from a HTTP server, so is it possible to get the headers or anything?
On the http example above, change :
Request.Method = Net.WebRequestMethods.Http.Head
'or
Request.Method = "Head"
That should do it.
Worked out, ty a lot =D
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.