示例#1
0
        public void BeginGetFile(string localFile, string remoteFile, FtpFileEventHandler callback)
        {
            InitHashtable();
            FtpFile file = (FtpFile)m_files[remoteFile];

            if (file == null)
            {
                throw new FtpException("Remote file (" + remoteFile + ") not found. Try refresh the directory.");
            }
            FtpFileTransferer transfer = new FtpFileTransferer(
                this,
                localFile,
                remoteFile,
                file.Size,
                TransferDirection.Download);

            transfer.StartAsyncTransfer(callback);
        }
示例#2
0
        public FtpOutputDataStream CreateFileStream(string newFileName)
        {
            InitHashtable();
            FtpDataStream stream = m_session.ControlChannel.GetPassiveDataStream(TransferDirection.Upload);

            try
            {
                m_session.ControlChannel.STOR(newFileName);
                FtpFile newFile = new FtpFile(this, newFileName);
                m_files[newFileName] = newFile;
                return((FtpOutputDataStream)stream);
            }
            catch (Exception)
            {
                stream.Dispose();
                throw;
            }
        }
 public FtpOutputDataStream CreateFileStream(string newFileName)
 {
     InitHashtable();
     FtpDataStream stream = m_session.ControlChannel.GetPassiveDataStream(TransferDirection.Upload);
     try
     {
         m_session.ControlChannel.STOR(newFileName);
         FtpFile newFile = new FtpFile(this, newFileName);
         m_files[newFileName] = newFile;
         return (FtpOutputDataStream)stream;
     }
     catch (Exception)
     {
         stream.Dispose();
         throw;
     }
 }