Quantcast
Channel: System.Net.FtpClient
Viewing all 741 articles
Browse latest View live

Created Unassigned: FtpCommandException: LIST command invalid with TYPE binary. [389]

$
0
0
I am getting the error
System.Net.FtpClient.FtpCommandException: LIST command invalid with TYPE binary.

I notice you are hard coding binary mode on listing. Could we have the option to specify an override using the FtpDataType?

Commented Unassigned: FtpCommandException: LIST command invalid with TYPE binary. [389]

$
0
0
I am getting the error
System.Net.FtpClient.FtpCommandException: LIST command invalid with TYPE binary.

I notice you are hard coding binary mode on listing. Could we have the option to specify an override using the FtpDataType?
Comments: I issued a PR that resolves this issue for me. https://netftp.codeplex.com/SourceControl/network/forks/shaneray/SystemNetFtpClient/contribution/7837

New Post: Internal error renaming the file

$
0
0
Hi, I have a problem when try to cut the file from one FTP directory to another.

Description, I have an infinity 'while", with "Thread.Sleep(60000)" (1 minute).
When loop start, I call "Connect" method, then "GetListing" (only files, not folders). Then I foreach files, download it to local machine (OpenRead, FtpDataType.Binary).

After copying, I call "Rename", to cut file from one FTP folder to another, but in this moment I catch "Internal error renaming the file".

But if I restart app, all work successfully (file move to another FTP directory, and I call "Disconnect" method).

Please help me)
Thanks!

New Post: FTP Quota and Used space

$
0
0
Hi, great component... Is there a way to display the quota the user has on the server, as well as the total size of all the files currently on the server?

Thanks,
Jacques

Created Unassigned: Reflection error OpenRead with EnableThreadSafeDataConnections [390]

$
0
0
When OpenRead is called with EnableThreadSafeDataConnections, I get the following error. Setting EnableThreadSafeDataConnections, it works.


Property set method not found.

Exception Type: System.ArgumentException
Exception Source: mscorlib @ SetValue

Stack Trace:
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
at System.Net.FtpClient.FtpClient.CloneConnection()
at System.Net.FtpClient.FtpClient.OpenRead(String path, FtpDataType type, Int64 restart)
at System.Net.FtpClient.FtpClient.OpenRead(String path, FtpDataType type)
at OnPoint.BackupService.ArvixeFtpClient.DownloadFile(String directory, String filename) in c:\vsts_ws\OnPoint\Main\Source\OnPoint.BackupService\OnPoint.BackupService\ArvixeFtpClient.cs:line 97
at OnPoint.BackupService.ArvixeFtpClient.DownloadFile(String filename) in c:\vsts_ws\OnPoint\Main\Source\OnPoint.BackupService\OnPoint.BackupService\ArvixeFtpClient.cs:line 82
at OnPoint.BackupService.BackupService.Backup() in c:\vsts_ws\OnPoint\Main\Source\OnPoint.BackupService\OnPoint.BackupService\BackupService.cs:line 55

New Post: GetModifiedTime overload that returns raw MDTM result.

$
0
0
I just found a device I have which uses BusyBox's ftpd, returns date in YYYYMMDDhhmmss format, except that the month is 0-based. So GetModifiedTime returns the wrong date. Can we possibly get GetModifiedTime that returns the raw reply of MDTM. I figure there must be a few other ftp servers that has uncommon date formats.

New Post: Raw Commands?

$
0
0
How to send raw commands to ftp server?, is it supported? if yes can anyone give an example?

New Post: FtpClient - Property set method not found in a derived type

$
0
0
When I made a derived class:
public class MyFtpClient : System.Net.FtpClient.FtpClient
I recieved the error "Property set method not found" on myFtpClient.OpenRead(filePath) - because, it turns out, the base class has a private setter for ClientCertificates:
public X509CertificateCollection ClientCertificates {
            get {
                return m_clientCerts;
            }
            private set {
                m_clientCerts = value;
            }
        }
So in order to enable a fully functioning derived class, I had to edit FtpClient.cs line 621, from:
prop.SetValue(conn, prop.GetValue(this, null), null);
to:
PropertyInfo baseProperty = prop.DeclaringType.GetProperty(prop.Name);
baseProperty.SetValue(conn, prop.GetValue(this, null), null);
Just thought I'd share. Thanks for a great library :)

New Post: Any plans to make it more async/await friendly?

$
0
0
You can convert easily between Async Callback and IAsyncResult programming patterns using Task<>.Factory.FromAsync

For example:
            FtpClient client = ...
            Stream s = await Task<Stream>.Factory
                .FromAsync(Client.BeginOpenRead, Client.EndOpenRead, path, Client);
You can also make it handle cancellation:
            FtpClient client = ...
            Stream s = await Task<Stream>.Factory
                .FromAsync(Client.BeginOpenRead, Client.EndOpenRead, path, Client)
                .HandleCancellation(Token);
HandleCancellation is a helper method that I got from StackOverflow.

It goes like this:
namespace MyNamespace
{
    /// <summary>
    /// Task.Factory.FromAsync does not come with cancellationtokensource built in.  
    /// This extension method allows us to handle that kind of behavior anyways.
    /// 
    /// This code came from:
    /// <see href="https://stackoverflow.com/questions/24980427/task-factory-fromasync-with-cancellationtokensource"/>.
    /// </summary>
    public static class TaskExtensions
    {
        public async static Task<TResult> HandleCancellation<TResult>(
            this Task<TResult> asyncTask,
            CancellationToken cancellationToken)
        {
            // Create another task that completes as soon as cancellation is requested.
            // http://stackoverflow.com/a/18672893/1149773
            var tcs = new TaskCompletionSource<TResult>();
            cancellationToken.Register(() => tcs.TrySetCanceled(), false);
            var cancellationTask = tcs.Task;

            // Create a task that completes when either the async operation completes,
            // or cancellation is requested.
            var readyTask = await Task.WhenAny(asyncTask, cancellationTask);

            // In case of cancellation, register a continuation to observe any unhandled 
            // exceptions from the asynchronous operation (once it completes).
            // In .NET 4.0, unobserved task exceptions would terminate the process.
            if (readyTask == cancellationTask)
            {
                await asyncTask.ContinueWith(_ => asyncTask.Exception,
                    TaskContinuationOptions.OnlyOnFaulted |
                    TaskContinuationOptions.ExecuteSynchronously);
            }
            return await readyTask;
        }
    }
}

New Post: Raw Commands?

New Post: Bulk Download - IOException: The connection was terminated before a greeting could be read.

$
0
0
Great package.

I'm doing a bulk download a large number of files (mainly pdfs but some zips and text files as well), and I encounter an unusual problem some time into the download.

I am using an asynchronous breadth-first traversal function in order to crawl through an FTP site and download all the files in each leaf node. It explores around 3000 folders and ends up queueing around 3168 files asynchronously using the following code
            Logger.Info("Download started");
            Stream s = await Task<Stream>.Factory
                .FromAsync(Client.BeginOpenRead, Client.EndOpenRead, path, Client)
The stream is then passed to a function which writes it to a file and logs "Wrote file". The log file can be summed up like this:
First ~3000 lines - Download started
Next ~200 lines - Interleaved "Download Started" and "Wrote file" messages
Next ~1000 lines - "Wrote File" messages
The problem is that after this point, I start getting this exception:
System.IO.IOException was caught
  HResult=-2146232800
  Message=The connection was terminated before a greeting could be read.
  Source=mscorlib
  StackTrace:
    Server stack trace: 
       at System.Net.FtpClient.FtpClient.Connect()
       at System.Net.FtpClient.FtpClient.OpenRead(String path, FtpDataType type, Int64 restart)
       at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
       at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
       at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
       at System.Net.FtpClient.FtpClient.AsyncOpenRead.EndInvoke(IAsyncResult result)
       at System.Net.FtpClient.FtpClient.EndOpenRead(IAsyncResult ar)
       at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
What is causing this problem, and how could I go about preventing, avoiding, or tolerating this problem?

Created Unassigned: SetDataType method is now protected not public. [391]

$
0
0
I'm not sure why this method has been set to protected. I commented out my use of it but I would like ot have this set back to public so I can specify the transfer type rather than relying on it to be implied.

Version is 1.0.5281.14359. I just updated the DLL today via nuget and this error occurred.

New Post: How to create mirror of FTP files to local directory?

$
0
0
Hi,
How to create mirror of all remote FTP files to local directory using FtpClient?

Can you provide sample code

Created Unassigned: EPSV implementation not compliant with some FTP servers [392]

$
0
0
EPSV is not working when trying to connect to some FTP Server (sorry, we don't know any details about this server).
Here is the error:
"System.Net.FtpClient.FtpException : Failed to get the EPSV port from: Entering Extended Passive Mode (__!!!51603!__). at System.Net.FtpClient.FtpClient.OpenPassiveDataStream(" [...]

I think that the line 1087 of the function "OpenPassiveDataStream" from the file "FtpClient.cs" is incorrect :
```
m = Regex.Match(reply.Message, @"\(\|\|\|(?<port>\d+)\|\)");
```
So the __client is expecting the "|" character__, and the server we are facing __is responding with the "!" character__.
This "!" seems to be allowed by the [RFC 2428](https://tools.ietf.org/html/rfc2428), which indeed recommands the "|", but allows any ASCII separator from 33 to 126.

Reference: RFC 2428, search for "The EPSV Command" and also "delimiter"

I don't know much about Regex, but going to modify it to accept 33 to 126 delimiters.
Please correct me if i'm wrong somewhere.

Edited Unassigned: EPSV implementation not compliant with some FTP servers [392]

$
0
0
EPSV is not working when trying to connect to some FTP Server (sorry, we don't know any details about this server).
Here is the error:
"System.Net.FtpClient.FtpException : Failed to get the EPSV port from: Entering Extended Passive Mode (__!!!51603!__). at System.Net.FtpClient.FtpClient.OpenPassiveDataStream(" [...]

I think that the line 1087 of the function "OpenPassiveDataStream" from the file "FtpClient.cs" is incorrect :
```
m = Regex.Match(reply.Message, @"\(\|\|\|(?<port>\d+)\|\)");
```
So the __client is expecting the "|" character__, and the server we are facing __is responding with the "!" character__.
This "!" seems to be allowed by the [RFC 2428](https://tools.ietf.org/html/rfc2428), which indeed recommands the "|", but allows any ASCII separator from 33 to 126.

Reference: RFC 2428, search for "The EPSV Command" and also "delimiter"

I don't know much about Regex, but going to modify it to accept 33 to 126 delimiters.
Please correct me if i'm wrong somewhere.

EDIT:
Modified 1087 line to accept 33-126 delimiters in passive mode :
```
m = Regex.Match(reply.Message, @"\([\x21-\x7E][\x21-\x7E][\x21-\x7E](?<port>\d+)[\x21-\x7E]\)");
```

New Post: AutoPassive not working?

$
0
0
We faced the same problem.
In order for "AutoPassive" to work as expected (try EPSV, and then PASV), you might need to force IPV4 :
ftpClient.InternetProtocolVersions = FtpIpVersion.IPv4;
The component default is IPV4 | IPV6.

Take a look on the component inner code :
          if (type == FtpDataConnectionType.EPSV || type == FtpDataConnectionType.AutoPassive) {
                if (!(reply = Execute("EPSV")).Success) {
                    // if we're connected with IPv4 and data channel type is AutoPassive then fallback to IPv4
                    if (reply.Type == FtpResponseType.PermanentNegativeCompletion && type == FtpDataConnectionType.AutoPassive && m_stream != null && m_stream.LocalEndPoint.AddressFamily == Sockets.AddressFamily.InterNetwork)
                        return OpenPassiveDataStream(FtpDataConnectionType.PASV, command, restart);
                    throw new FtpCommandException(reply);
                }

Created Unassigned: Received an unexception EOF or 0 bytes from the transport stream [393]

$
0
0
I'm getting this error "Received an unexception EOF or 0 bytes from the transport stream " When I downloading fifth file in eight files from ftp server.

I'm trying different way usage filezilla and I'm getting this error;

Error: GnuTLS error -110 in gnutls_record_recv: The TLS connection was non-properly terminated.
Status: Server did not properly shut down TLS connection
Error: Could not read from transfer socket: ECONNABORTED - Connection aborted
Error: File transfer failed after transferring 97.571 bytes in 1 second

Do you have an idea? What should I do ?


New Post: Auto-reconnect and SetWorkingDirectory

$
0
0
I have an application using System.Net.FtpClient which runs 24/7, every few minutes it connects to an ftp server, does a SetWorkingDirectory, uploads a few files, and then disconnects.

It appears that when I have connection issues in the middle of the uploads, the session gets automatically reconnected, which is nice, but it means that the remaining files get uploaded to the wrong directory.

Is my assessment correct, and if so, is there anything I can do? Perhaps I should avoid using SetWorkingDirectory, and I should append the path to the front of the remote filename instead?

Steve

New Post: Auto-reconnect and SetWorkingDirectory

$
0
0
Hi Steve,

The best solution for now is going to be to use absolute paths. You are right that System.Net.FtpClient doesn't remember the working directory between reconnects. You could modify it to save it to a protected clone-able property (check some of the other properties to see the attribute) in the FtpClass and have the Connect method check it and set it as needed. It needs the clone attribute added so that if you use the thread safe data channels feature the working directory gets copied over to new instances of FtpClient created internally.

New Post: Auto-reconnect and SetWorkingDirectory

$
0
0
Thanks - I'll go with the absolute paths and maybe look at modifying it later when I have more time.

Steve
Viewing all 741 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>