Пример #1
0
 public void GetFile(string path, MemoryStream memStream)
 {
     lock (commandLock)
     {
         FtpResponseCollection response = null;
         try
         {
             CheckConnected();
             // replace the windows style directory delimiter with a unix style delimiter
             path = NormaliseForFTP(path);
             FtpRequest request = new FtpRequest(FtpRequest.BuildCommandText("RETR", ftpInstance.CharacterEncoding, new string[] { path }));
             ftpInstance.TransferData(TransferDirection.ToClient, request, memStream);
             response = ftpInstance.LastResponseList;
         }
         catch
         {
             if ((response == null) &&
                 (memStream.Position != memStream.Length)
                 )
             {
                 // This means that the expected read of the fragment did not complete and aborted for another reason
                 throw;
             }
         }
     }
 }
Пример #2
0
 public FtpResponseCollection Feature(bool useNewResponseList, Features feature, bool UTFEncodeArg = false, params string[] arguments)
 {
     if ((SupportedFeatures & feature) != feature)
     {
         throw new ActionNotSupportedException(string.Format("FTP Target server does not support the {0} command", feature));
     }
     lock (commandLock)
         return(Quote(FtpRequest.BuildCommandText(feature.ToString(), UTFEncodeArg?ftpInstance.CharacterEncoding:Encoding.ASCII, arguments), useNewResponseList));
 }