![]() ![]() The code sets the request’s ContentLength property to the length of the text to be uploaded and gets a request stream that it can use to write the text. 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, text.Length) Using (Stream request_stream = request.GetRequestStream())īyte bytes = (text) Write the text's bytes into the request stream. New NetworkCredential(user_name, password) (FtpWebRequest)WebRequest.Create(to_uri) Get the object used to communicate with the server. Private void FtpUploadString(string text, 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |