index.aspx
<%@ Page Language="c#" %>
Please enter your name:
Please enter your address:
Please enter your password:
Result.aspx
<%@ Page Language="c#" ValidateRequest="false" %>
Text Box Example
Connect to FTP
using System; using System.IO; using System.Net; namespace FTPExample { class Program { static void Main(string[] args) { // FTP server details string ftpServer = "ftp://yourftpserver.com"; string username = "your-ftp-username"; string password = "your-ftp-password"; // Local file to upload string localFilePath = @"C:\path\to\your\file.txt"; string remoteFileName = "file.txt"; // The name you want the file to have on the FTP server // Create a URI for the FTP server Uri ftpUri = new Uri(ftpServer + "/" + remoteFileName); // Create an FtpWebRequest object FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpUri); request.Method = WebRequestMethods.Ftp.UploadFile; // Set credentials request.Credentials = new NetworkCredential(username, password); // Read the file to be uploaded into a byte array byte[] fileContents; using (StreamReader sourceStream = new StreamReader(localFilePath)) { fileContents = System.Text.Encoding.UTF8.GetBytes(sourceStream.ReadToEnd()); } // Set the content length request.ContentLength = fileContents.Length; // Get the request stream using (Stream requestStream = request.GetRequestStream()) { // Upload the file requestStream.Write(fileContents, 0, fileContents.Length); } // Get the response using (FtpWebResponse response = (FtpWebResponse)request.GetResponse()) { Console.WriteLine($"Upload File Complete, status {response.StatusDescription}"); } } } }