Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.1k views
in .NET FTP by (160 points)
Hi,

I'm having problems with uploading files using binary transfer type.

Connecting and changing dir happens as supposed to, however aparently I do not get the transfer type set correctly or somthing.

Before attempting to use binary i got the following error when trying to upload a bmp file:
--------------------
Found a high surrogate char without a following low surrogate at index: 252.
The input may not be in this encoding, or may not contain valid Unicode (UTF-16) characters. Parameter name: chars
--------------------

I assumed that this was due to the binary nature of the file and attempted to switch to binary mode through:
--------------------
objFTPClient.TransferType = FTPTransferType.BINARY;
--------------------
I use FTPClient and not FTPConnection by the way, should I be using FTPConnection instead and if so, why?

Anyway, after I did this and then use put() I get:
--------------------
Unable to write data to the transport connection.
--------------------

I've searched the forum and seen examples using setType() but I cannot find this function in any of the namespaces nor can I find it in the source files included with the download.
It's the free version I'm using by the way since I wanna make sure this thing can do when I need before I buy it.

If anyone is able to illuminate me a bit on this topic it would be much appreciated.

/Aidal

3 Answers

0 votes
by (162k points)
FTPClient is basically deprecated and all users are encouraged to use FTPConnection (which uses FTPClient internally for the time being).

If you are using FTPClient, set the property TransferType as you seem to have. Transferring bmp files you should always use binary mode.

Also, you may need to switch between active and passive modes depending on your firewall - try both (see ConnectMode) - that could be the cause of the problem you describe.
0 votes
by (160 points)
I have now tried all the above and on several different FTP servers as well.

I've also re-written all code to use the FTPConnection class instead of the FTPClient class.

However, the binary upload still doesn't work while everything else does.
Or, I'm not sure it's actually the binary upload that fails, but maybe rather the change of transfer type that doesn't go through.

I'm using the following (this.con = an open FTPConnection):
---------------------------------------------------------------------
this.con.TransferType = FTPTransferType.BINARY;

or

this.con.TransferType = FTPTransferType.ASCII;
---------------------------------------------------------------------

They both seem to fail for some reason.
Wether it's my syntax that's is wrong or whatever it is I don't know but it fails every time regardless of which FTP server I try it on and regardless of connection mode.
0 votes
by (51.6k points)
In what way does it fail? It helps if you can include an exception (with stack-trace) and logging (see FTPConnection.LogLevel and LogFile).

- Hans (EDT)

Categories

...