예제 #1
0
파일: CFtp2.cs 프로젝트: doctorgu/MadeIn9
        /// <summary>
        /// FTP 서버에 메모리 상에 있는 Stream을 업로드함.
        /// </summary>
        /// <param name="str">Stream 개체</param>
        /// <param name="RemoteFolder">서버의 폴더 위치</param>
        /// <param name="RemoteFile">서버의 파일 이름</param>
        public void UploadStream(Stream str, string RemoteFolder, string RemoteFile)
        {
            Uri RemoteUri = GetRemoteUri(RemoteFolder, RemoteFile);

            FtpWebRequest FtpReq = (FtpWebRequest)WebRequest.Create(RemoteUri);

            if (!string.IsNullOrEmpty(this._Info.UserId))
            {
                FtpReq.Credentials = new NetworkCredential(this._Info.UserId, this._Info.Password);
            }
            FtpReq.UsePassive = this._Info.UsePassive;

            FtpReq.Method = WebRequestMethods.Ftp.UploadFile;

            Stream writeStream = FtpReq.GetRequestStream();

            byte[] aByte = CFile.GetByteFromStream(str);
            writeStream.Write(aByte, 0, aByte.Length);

            writeStream.Close();

            return;
        }