FTP下载文件实例
private void button1_Click(object sender, EventArgs e)
{
FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(textBox1.Text);
ftpRequest.Credentials = new NetworkCredential(textBox2.Text,textBox3.Text);
FtpWebResponse ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
Stream data = ftpResponse.GetResponseStream();
string str = textBox1.Text.Substring(textBox1.Text.LastIndexOf("/"), textBox1.Text.Length - textBox1.Text.LastIndexOf("/"));
string SavePath = str;
if (File.Exists(SavePath))
{
File.Delete(str);
}
byte[] buffer = new byte[4096];
FileStream stream =new FileStream(SavePath,FileMode.Create);
int count = 0;
do
{
count = data.Read(buffer, 0, buffer.Length);
if (count > 0)
{
stream.Write(buffer, 0, count);
}
}
while (count > 0);
ftpResponse.Close();
stream.Close();
}
资源文件列表
FTP╧┬╘╪/DFTPFile.sln , 914
FTP╧┬╘╪/DFTPFile.suo , 30208
FTP╧┬╘╪/DFTPFile/bin/Debug/DFTPFile.exe , 32256
FTP╧┬╘╪/DFTPFile/bin/Debug/DFTPFile.pdb , 24064
FTP╧┬╘╪/DFTPFile/bin/Debug/DFTPFile.vshost.exe , 14328
FTP╧┬╘╪/DFTPFile/DFTPFile.csproj , 3762
FTP╧┬╘╪/DFTPFile/Form1.cs , 1537
FTP╧┬╘╪/DFTPFile/Form1.designer.cs , 32520
FTP╧┬╘╪/DFTPFile/Form1.resx , 24351
FTP╧┬╘╪/DFTPFile/obj/Debug/DFTPFile.csproj.FileListAbsolute.txt , 723
FTP╧┬╘╪/DFTPFile/obj/Debug/DFTPFile.csproj.GenerateResource.Cache , 847
FTP╧┬╘╪/DFTPFile/obj/Debug/DFTPFile.exe , 32256
FTP╧┬╘╪/DFTPFile/obj/Debug/DFTPFile.Form1.resources , 13820
FTP╧┬╘╪/DFTPFile/obj/Debug/DFTPFile.pdb , 24064
FTP╧┬╘╪/DFTPFile/obj/Debug/DFTPFile.Properties.Resources.resources , 180
FTP╧┬╘╪/DFTPFile/Program.cs , 489
FTP╧┬╘╪/DFTPFile/Properties/AssemblyInfo.cs , 1372
FTP╧┬╘╪/DFTPFile/Properties/Resources.Designer.cs , 2866
FTP╧┬╘╪/DFTPFile/Properties/Resources.resx , 5612
FTP╧┬╘╪/DFTPFile/Properties/Settings.Designer.cs , 1093
FTP╧┬╘╪/DFTPFile/Properties/Settings.settings , 249
