Esempio n. 1
0
        //----------------------------------------------------------------------------------------------
        /// <summary>
        /// Make a FTP request to get a file from the server.
        /// It will raise an event on the BaseHandler, when done
        /// </summary>
        /// <param name="target"> url that is the name of the file being uploaded to the server</param>
        /// <param name="state">holds all the required data as supplied by the caller</param>
        /// <param name="user">username used to connect to the server</param>
        /// <param name="passwrd">username used to connect to the server</param>
        public static void DownloadRequest(Uri target, FtpState state, string user, string passwrd)
        {
            try
            {
                SetupRequest(target, state, state.FileName.Name, user, passwrd);
                state.MRequest.Method = WebRequestMethods.Ftp.DownloadFile;
                //
                // Store the request in the object that we pass into the
                // asynchronous operations.
                // Asynchronously get the stream for the file contents.
                //
                state.MRequest.BeginGetResponse(EndDownloadResponseCallback,
                    state);


                //.BeginGetRequestStream(
                //    new AsyncCallback(EndDownloadGetStreamCallback),
                //    state
                //);
            }
            catch (Exception e)
            {
                state.RaiseException(e);
            }
        }
Esempio n. 2
0
 //----------------------------------------------------------------------------------------------
 /// <summary>
 /// Make a FTP request to put a file onto the server.
 /// It will raise an event on the BaseHandler, when done
 /// </summary>
 /// <param name="target"> url that is the name of the file being uploaded to the server</param>
 /// <param name="state">holds all the required data as supplied by the caller</param>
 /// <param name="user">username used to connect to the server</param>
 /// <param name="passwrd">username used to connect to the server</param>
 public static void UploadRequest(Uri target, FtpState state, string user, string passwrd)
 {
     try
     {
         if (!state.FileName.Exists)
         {
             throw new Exception("FTP_Handler::UploadRequest file: " + state.FileName.FullName
                 + " does not exist");
         }
         SetupRequest(target, state, state.FileName.Name, user, passwrd);
         state.MRequest.Method = WebRequestMethods.Ftp.UploadFile;
         //
         // Store the request in the object that we pass into the
         // asynchronous operations.
         // Asynchronously get the stream for the file contents.
         //
         state.MRequest.BeginGetRequestStream(EndUploadGetStreamCallback,
             state
         );
     }
     catch (Exception e)
     {
         state.RaiseException(e);
     }
 }