If you are using a username and password, fill them in on the main form. The example shown in the picture assumes you are using anonymous FTP. Next the program creates a NetworkCredentials object to identify the account being used to upload the file. The code starts by creating a WebRequest object associated with the URI and by setting its Method property to UploadFile. Request_stream.Write(bytes, 0, bytes.Length) Using (Stream request_stream = request.GetRequestStream()) Write the bytes into the request stream. Read the file's contents into a byte array.īyte bytes = System.IO.File.ReadAllBytes(filename) New NetworkCredential(user_name, password) (FtpWebRequest)WebRequest.Create(to_uri) Get the object used to communicate with the server. Private void FtpUploadFile(string filename, string to_uri, The other parameters are self-explanatory. The to_uri parameter is a URI (Uniform Resource Identifier) that identifies the target file as in. The following FtpUploadFile method uploads a file to an FTP server.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |