|
[qq]1025768519[/qq][img]file:///C:/Users/Administrator/AppData/Roaming/Tencent/Users/1025768519/QQ/WinTemp/RichOle/%7BO[94JK%7BJ%7B%25]RK7%25TGI7USM.jpg[/img] 求解释下这是什么问题。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
string server;
string usernam;
string passwor;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
FtpWebRequest req;
server = ipaddress.Text;
usernam = username.Text;
passwor = password.Text;
req = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + server + "/"));
req.Credentials = new NetworkCredential(usernam, passwor);
req.KeepAlive = false;
req.Method = WebRequestMethods.Ftp.ListDirectory;
req.UseBinary = true;
WebResponse response = req.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string line = reader.ReadLine();
while (line != null)
{
ftpfilelist.Items.Add(line);
line = reader.ReadLine();
}
reader.Close();
response.Close();
button1.Enabled = false;
}
}
}
|
|