How to obtain the size of a stream from a FTP-server

  • Thread starter Thread starter K Viltersten
  • Start date Start date
K

K Viltersten

I've used something along the lines of this.

Stream stream = download.getRequestStream();
int reply = 0;
while( reply >= 0) {
reply = stream.read();
list.add( reply );
}

I'd prefer to use read(byte[], int, int) for
performance reasons but for that i need to
obtain the size of the file to be downloaded.

I've tried the following but i only get an
error about this verb type not being sendable.

long s = download.GetRequestStream().Length;

How can i do that?
 
long s = download.GetRequestStream().Length;
What type has download? WebRequest?

Yes, it has. FtpWebRequest, to be precise.
Then you may take a look at

(WebRequest)download.ContentLength.

Doing that gave me the value of zero...
Suggestions?
 
Back
Top