Ejemplo n.º 1
0
        public void Download(string cpath, string lpath)
        {
            lock (ftpcLock)
            {
                using (Stream file = File.OpenWrite(lpath), rem = _ftpc.OpenRead(cpath))
                {
                    var buf = new byte[8192];
                    int read;

                    while ((read = rem.Read(buf, 0, buf.Length)) > 0)
                    {
                        file.Write(buf, 0, read);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void Download(string cpath, string lpath)
        {
            if (FTP)
            {
                using (Stream file = File.OpenWrite(lpath), rem = _ftpc.OpenRead(cpath))
                {
                    var buf = new byte[8192];
                    int read;

                    while ((read = rem.Read(buf, 0, buf.Length)) > 0)
                    {
                        file.Write(buf, 0, read);
                    }
                }
            }
            else
            {
                using (var f = new FileStream(lpath, FileMode.Create, FileAccess.ReadWrite))
                    _sftpc.DownloadFile(cpath, f);
            }
        }