Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Net;
- using System.IO;
- namespace ftp_test
- {
- class Program
- {
- static void Main(string[] args)
- {
- FtpWebRequest ftp;
- string f_address;
- string f_user;
- string f_pass;
- Console.WriteLine("Please enter an ftp address:");
- f_address = Console.ReadLine();
- Console.WriteLine("\nuser:");
- f_user = Console.ReadLine();
- Console.WriteLine("\npass:");
- f_pass = Console.ReadLine();
- ftp = (FtpWebRequest)FtpWebRequest.Create(f_address);
- ftp.Credentials = new NetworkCredential(f_user, f_pass);
- Console.Clear();
- ftp.Method = WebRequestMethods.Ftp.ListDirectory;
- WebResponse response = ftp.GetResponse();
- StreamReader reader = new StreamReader(response.GetResponseStream());
- Console.WriteLine("Directory Listing:");
- string line = reader.ReadLine();
- while (line != null)
- {
- Console.WriteLine(line);
- line = reader.ReadLine();
- }
- Console.WriteLine("\nenter to exit");
- Console.ReadLine();
- }
- }
- }
Add Comment
Please, Sign In to add comment