91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 109KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-06-08
  • 語言: C#
  • 標(biāo)簽: ftp??

資源簡介

基于C#的FTP客戶端的實現(xiàn)(網(wǎng)絡(luò)編程課設(shè)),基本實現(xiàn)了FTP客戶端的功能,可以當(dāng)課程設(shè)計用。

資源截圖

代碼片段和文件信息

using?System;
using?System.IO;
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.Net;

namespace?FTPclient
{
????public?partial?class?Form1?:?Form
????{
????????string?ftpServerIP;//服務(wù)器IP
????????string?ftpUserID;//用戶名
????????string?ftpPwd;//密碼
????????
????????static??string?file?=?null;
????????FtpWebRequest?reqFTP;
????????public?Form1()
????????{
????????????InitializeComponent();
????????}

????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????btn_reconnect.Enabled?=?false;
????????????txt_serverIp.Text?=?ftpServerIP;
????????????txt_username.Text?=?ftpUserID;
????????????txt_pwd.Text?=?ftpPwd;
????????????this.Text?+=?ftpServerIP;

????????????btn_connect.Enabled?=?true;
????????????btn_stepback.Enabled?=?false;
????????}
????????private?void?Connect(String?path)//連接ftp

????????{
????????????//?根據(jù)uri創(chuàng)建FtpWebRequest對象
????????????reqFTP?=?(FtpWebRequest)FtpWebRequest.Create(new?Uri(path));
????????????//?指定數(shù)據(jù)傳輸類型
????????????reqFTP.UseBinary?=?true;
????????????//?ftp用戶名和密碼
????????????reqFTP.Credentials?=?new?NetworkCredential(ftpUserID?ftpPwd);
????????}

????????//上傳
????????private?void?Upload(string?filename)
????????{
????????????FileInfo?fileInf?=?new?FileInfo(filename);
????????????string?uri?=?“ftp://“+ftpServerIP+“/“+fileInf.Name;
????????????if?(file?!=?null)
????????????{
????????????????uri?=?“ftp://“?+?ftpServerIP?+?“/“?+?file+fileInf.Name;
????????????}

????????????//連接FTP
????????????Connect(uri);

????????????//默認(rèn)情況下KeepAlive是true?
????????????reqFTP.KeepAlive?=?false;

????????????//指定要執(zhí)行的命令
????????????reqFTP.Method?=?WebRequestMethods.Ftp.UploadFile;
???????????
????????????//指定要傳輸?shù)臄?shù)據(jù)類型
????????????reqFTP.UseBinary?=?true;
????????????
????????????//指定上傳文件的長度
????????????reqFTP.ContentLength?=?fileInf.Length;

????????????//緩沖區(qū)大小設(shè)置成KB
????????????int?buffLength?=?2048;
????????????byte[]?buff?=?new?byte[buffLength];
????????????int?contentLen;

????????????//打開一個文件流讀入上傳的文件
????????????FileStream?fs?=?fileInf.OpenRead();
????????????try
????????????{
????????????????//吧要上傳的文件寫入流
????????????????Stream?strm?=?reqFTP.GetRequestStream();
????????????????
????????????????//從文件流中讀入數(shù)據(jù),一次讀2LB大小的數(shù)據(jù)
????????????????contentLen?=?fs.Read(buff0buff.Length);
????????????????while(contentLen!=0)
????????????????{
????????????????????//把文件的內(nèi)容從文件流寫到FTP上傳流中
????????????????????strm.Write(buff0contentLen);
????????????????????contentLen?=?fs.Read(buff0buffLength);
????????????????}
????????????????//關(guān)閉文件流和請求流
????????????????strm.Close();
????????????????fs.Close();
????????????????detailListfile();
????????????}
????????????catch?(Exception?e)
????????????{
????????????????MessageBox.Show(e.Message“上傳出錯“);
????????????}
????????????finally
????????????{
?
????????????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-10-07?10:22??MyFtpClient\
?????目錄???????????0??2015-10-07?10:23??MyFtpClient\FTPclient\
?????目錄???????????0??2015-10-07?10:23??MyFtpClient\FTPclient\Backup\
?????目錄???????????0??2015-10-07?10:23??MyFtpClient\FTPclient\Backup\FTPclient\
?????文件????????3764??2008-12-13?11:26??MyFtpClient\FTPclient\Backup\FTPclient\FTPclient.csproj
?????文件???????21822??2008-12-18?08:37??MyFtpClient\FTPclient\Backup\FTPclient\Form1.Designer.cs
?????文件???????18462??2008-12-18?12:45??MyFtpClient\FTPclient\Backup\FTPclient\Form1.cs
?????文件????????5814??2008-12-18?08:37??MyFtpClient\FTPclient\Backup\FTPclient\Form1.resx
?????文件?????????490??2008-12-13?10:51??MyFtpClient\FTPclient\Backup\FTPclient\Program.cs
?????目錄???????????0??2015-10-07?10:23??MyFtpClient\FTPclient\Backup\FTPclient\Properties\
?????文件????????1360??2008-12-13?10:51??MyFtpClient\FTPclient\Backup\FTPclient\Properties\AssemblyInfo.cs
?????文件????????2868??2008-12-13?10:51??MyFtpClient\FTPclient\Backup\FTPclient\Properties\Resources.Designer.cs
?????文件????????5612??2008-12-13?10:51??MyFtpClient\FTPclient\Backup\FTPclient\Properties\Resources.resx
?????文件????????1094??2008-12-13?10:51??MyFtpClient\FTPclient\Backup\FTPclient\Properties\Settings.Designer.cs
?????文件?????????249??2008-12-13?10:51??MyFtpClient\FTPclient\Backup\FTPclient\Properties\Settings.settings
?????文件?????????917??2008-12-13?10:51??MyFtpClient\FTPclient\Backup\FTPclient.sln
?????文件???????14848??2008-12-18?16:09??MyFtpClient\FTPclient\Backup\FTPclient.v12.suo
?????目錄???????????0??2015-10-17?08:52??MyFtpClient\FTPclient\FTPclient\
?????文件????????3954??2015-10-07?23:40??MyFtpClient\FTPclient\FTPclient\FTPclient.csproj
?????文件???????23080??2015-10-07?23:40??MyFtpClient\FTPclient\FTPclient\Form1.Designer.cs
?????文件???????20858??2015-10-17?08:52??MyFtpClient\FTPclient\FTPclient\Form1.cs
?????文件????????5814??2015-10-07?23:08??MyFtpClient\FTPclient\FTPclient\Form1.resx
?????文件?????????490??2008-12-13?10:51??MyFtpClient\FTPclient\FTPclient\Program.cs
?????目錄???????????0??2015-10-07?10:22??MyFtpClient\FTPclient\FTPclient\Properties\
?????文件????????1360??2008-12-13?10:51??MyFtpClient\FTPclient\FTPclient\Properties\AssemblyInfo.cs
?????文件????????2858??2015-10-07?10:23??MyFtpClient\FTPclient\FTPclient\Properties\Resources.Designer.cs
?????文件????????5612??2008-12-13?10:51??MyFtpClient\FTPclient\FTPclient\Properties\Resources.resx
?????文件????????1109??2015-10-07?10:23??MyFtpClient\FTPclient\FTPclient\Properties\Settings.Designer.cs
?????文件?????????249??2008-12-13?10:51??MyFtpClient\FTPclient\FTPclient\Properties\Settings.settings
?????目錄???????????0??2008-12-13?10:51??MyFtpClient\FTPclient\FTPclient\bin\
?????目錄???????????0??2015-10-17?08:52??MyFtpClient\FTPclient\FTPclient\bin\Debug\
............此處省略22個文件信息

評論

共有 條評論