//---------------------------------------------------------------------------------------------- /// <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( new AsyncCallback(EndUploadGetStreamCallback), state ); } catch (Exception e) { state.RaiseException(e); } }
//---------------------------------------------------------------------------------------------- /// <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( new AsyncCallback(EndDownloadResponseCallback), state); //.BeginGetRequestStream( // new AsyncCallback(EndDownloadGetStreamCallback), // state //); } catch (Exception e) { state.RaiseException(e); } }