As FtpState = New FtpState() Dim request As FtpWebRequest = CType(WebRequest.Create(target), FtpWebRequest) request.Method = WebRequestMethods.Ftp.UploadFile request.Credentials = New NetworkCredential(args(2), args(3)) state.Request1 = request state.FileName1 = fileName waitObject = state.OperationComplete request.BeginGetRequestStream(New AsyncCallback(AddressOf EndGetStreamCallback), state) waitObject.WaitOne() If Not state.OperationException1 Is Nothing Then Throw As FtpState = CType(ar.AsyncState, FtpState) Dim requestStream As Stream = Nothing Try requestStream = state.Request1.EndGetRequestStream(ar) Dim bufferLength As Integer = 2048 Dim buffer() As Byte = New Byte(bufferLength) {} Dim count As FtpState = New FtpState() Dim request As FtpWebRequest = CType(WebRequest.Create(target), FtpWebRequest) request.Method = WebRequestMethods.Ftp.UploadFile request.Credentials = New NetworkCredential(args(2), args(3)) state.Request1 = request state.FileName1 = fileName waitObject = state.OperationComplete request.BeginGetRequestStream(New AsyncCallback(AddressOf EndGetStreamCallback), state) waitObject.WaitOne() If Not state.OperationException1 Is Nothing Then Throw As FtpState = CType(ar.AsyncState, FtpState) Dim requestStream As Stream = Nothing Try requestStream = state.Request1.EndGetRequestStream(ar) Dim bufferLength As Integer = 2048 Dim buffer() As Byte = New Byte(bufferLength) {} Dim count As FtpState = New FtpState() Dim request As FtpWebRequest = CType(WebRequest.Create(target), FtpWebRequest) request.Method = WebRequestMethods.Ftp.UploadFile request.Credentials = New NetworkCredential(args(2), args(3)) state.Request1 = request state.FileName1 = fileName waitObject = state.OperationComplete request.BeginGetRequestStream(New AsyncCallback(AddressOf EndGetStreamCallback), state) waitObject.WaitOne() If Not state.OperationException1 Is Nothing Then Throw
WebRequest.Create( "ftp: / / " + FTP + " / " + splitfile) 'Call A FileUpload Method of FTP Request Object reqObj.Method = WebRequestMethods.Ftp.UploadFile 'If you want to access Resourse Protected You need to give User Name fileName = args[1]; FtpState state = new FtpState(); FtpWebRequest request = (FtpWebRequest)WebRequest.Create(target); request.Method = WebRequestMethods.Ftp.UploadFile; / / This example uses anonymous logon. / / The request is anonymous by default; the credential to wait on. waitObject = state.OperationComplete; / / Asynchronously get the stream for the file contents. request.BeginGetRequestStream( new AsyncCallback (EndGetStreamCallback), state ); / / Block the current thread until all operations are complete. waitObject.WaitOne requestStream = null ; / / End the asynchronous call to get the request stream. try { requestStream = state.Request.EndGetRequestStream(ar); / / Copy the file contents to the request stream. const int bufferLength = 2048; byte [] buffer
fileName = args[1]; FtpState state = new FtpState(); FtpWebRequest request = (FtpWebRequest)WebRequest.Create(target); request.Method = WebRequestMethods.Ftp.UploadFile; / / This example uses anonymous logon. / / The request is anonymous by default; the credential to wait on. waitObject = state.OperationComplete; / / Asynchronously get the stream for the file contents. request.BeginGetRequestStream( new AsyncCallback (EndGetStreamCallback), state ); / / Block the current thread until all operations are complete. waitObject.WaitOne requestStream = null ; / / End the asynchronous call to get the request stream. try { requestStream = state.Request.EndGetRequestStream(ar); / / Copy the file contents to the request stream. const int bufferLength = 2048; byte[] buffer System. Net . FtpWebRequest ) • clsRequest. Credentials = New System. Net . NetworkCredential ( FtpUser, FtpPassword ) • • clsRequest. Method = System. Net . WebRequestMethods . Ftp . UploadFile • • Dim bFile ( ) As Byte = System. IO . File . ReadAllBytes ( filepath & " \ " & filename ) • • • Dim clsStream As