Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.6k views
in .NET FTP by (280 points)
hi,
I want to download the last 4K of a very large file into a byte array. I don't have the rest of the file locally.

Can this be done with the free library please?

Thanks.

8 Answers

0 votes
by (162k points)
Yes, you can do this via the FTP REST command. If you know the size of the file, subtract 4k from it to get x bytes.

Then do this:

ftp.InvokeFTPCommand("REST x")
ftp.DownloadByteArray(...)

I haven't actually tried this but I *think* it will work.
0 votes
by (280 points)
Hi Bruce,

I had tried that. For an 18 byte file called test.txt I did:

ftp.InvokeFTPCommand("REST 14", "350");
var bytes = ftp.DownloadByteArray("test.txt");

but this downloads all 18 bytes and not the last 4 as required.

Any thoughts please?
0 votes
by (280 points)
Also, this is whats coming back from the ftp server after the REST command in the LastValidReply of the FTPConnection:

REST supported. Restarting at 14
0 votes
by (162k points)
Please post the debug log here.
0 votes
by (280 points)
Not sure how to get the logs but I will check. Meanwhile if you repro it with an 18 byte text file and :

For an 18 byte file called test.txt I did:

ftp.InvokeFTPCommand("REST 14", "350");
var bytes = ftp.DownloadByteArray("test.txt");

but this downloads all 18 bytes and not the last 4 as required.

You will see it fail.
0 votes
by (162k points)
Take a look in the dev guide for the logging how to.
0 votes
by (280 points)
Hi,

I've confirmed its a bug in your downloadbytearray code with reflector. You always start at the beginning of the stream.
I don't have time to submit the debug logs when you've already got good repro steps and I can see from the code that it won't work.

I've had to move to a different FTP library thats supports downloading part of a file. Good luck in fixing the bug.
0 votes
by (162k points)
Ok thanks for the info. We never really thought people would use resume with a byte array!

Categories

...