FluentFTP icon indicating copy to clipboard operation
FluentFTP copied to clipboard

Opening a read stream on a remote file?

Open MarkBlaise opened this issue 8 months ago • 1 comments

First off, thanks for an extremely useful body of work! With the deprecation/obsolescence of System.Net.FtpClient, .NET now wants everyone to use HttpClient, but that oddly has no support for FTP ... go figure!

My issue is that I have some relatively large XML files on an FTP server, and I need to read a small part of the beginning of these files (a couple of attributes of specific elements), and I'd like to do this without having to download the entire file first.

System.Net.FtpClient has an OpenRead method that returns a file stream through which I can use an XmlTextReader to accomplish this task.

Does FluentFtp have anything similar to this? I was hopeful that I could use the DownloadStream method to do this, but it seems that this method downloads the entire file to the stream. This works, but I'd really like to avoid the time and bandwidth wasted downloading the whole file.

Thanks!

MarkBlaise avatar Mar 07 '26 15:03 MarkBlaise

OK, I finally looked more carefully at the overloads of the DownloadStream method, and I see that I can in fact limit how much of the file is downloaded ... duh!

Sorry about that!

MarkBlaise avatar Mar 07 '26 16:03 MarkBlaise