FtpWebResponse and StreamReader - specifying an offset
Posted
by AJ
on Stack Overflow
See other posts from Stack Overflow
or by AJ
Published on 2010-04-22T08:01:50Z
Indexed on
2010/04/22
8:03 UTC
Read the original article
Hit count: 218
Hi,
I am using the FtpWebRequest / FtpWebResponse objects in C# to download files from a server - so far, so good. I create a StreamReader object from the response stream and use a StreamWriter to create a local file.
Now, the file I am reading happens to be in a very simple 'archive' format - there is a small TOC at the start of the file followed by the actual file data. I can therefore read the TOC and get a file offset and size of the data I want to download.
My question is: Supposing the offset is 1024. I would use StreamReader.Read(buffer, 1024, length), but will .NET and the FTP protocol actually allow me to skip bytes 0-1023, or does the reader still go through the (relatively) slow process of downloading and discarding the bytes I don't need? This may make the difference between whether I want to use a single archive file, or a TOC file with the data files stored separately.
As a bit of a secondary question, would my mileage vary using the Http classes instead of Ftp?
Cheers, Adam
© Stack Overflow or respective owner