Yi Meng tcp file transfer and Automatic Update system introduction (TCP File Transfer) (four)
Yi Meng tcp file upload download and Automatic Update system introduction (TCP File Transfer)
The system is based on the open source Networkcomms communication framework, which was previously charged, is now free and open source, the author is British, the development time of more than 5 years, the framework is very stable.
Project Address: https://item.taobao.com/item.htm?spm=686.1000925.0.0.AjdBGP&id=537538462790
Consulting qq:286275658
The idea of File download
Demo Program: HTTP://PAN.BAIDU.COM/S/1GEVFMCR
Click the code for the list on the left:
ItemID = Listbox2.text; Lblid.text = Listbox2.text; Reload (ItemID);
View Code
When you click on the list on the left, the corresponding subfolder name (path name) is passed to the server. Depending on the subfolder name, the server gets a list of files in the subfolder, sent to the client, and displayed by the client.
User in the list on the right, click on a file to get the file name. and request the download of the file to the server based on the path name and file name
The code is roughly as follows:
void Itembutton_newdownfile (object sender, Fileeventargs e) {openflag = false; string fileName = E.fileinfo.name; Long fileSize = e.fileinfo.size; ULONG thefilesize = Convert.touint32 (fileSize); Gets the current file name extension string extentname = Path.getextension (fileName); try {string savepath = Filehelper.getpathtosave ("Select Save Path", fileName, NULL); if (Savepath! = null) {//If the user changes the name in a pop-up window, you need to manually add the extension if (!savepath.en Dswith (Extentname)) {Savepath = Savepath + extentname; }//Get the relative location of the directory such as: 201011\123456\ file. txt string fileuri = ItemID + @ "\" + fileName; try {fileinfocontract contract = new Fileinfocontract (Savepa th, Fileuri); Appoutter.tcpconn.sEndObject ("DownloadFile", contract); } catch (Exception ee) {MessageBox.Show (EE. Message); }}} catch (Exception ee) {MessageBox.Show (EE. Message); } }
qq:286275658
Yi Meng tcp file transfer and Automatic Update system introduction (TCP File Transfer) (four)