Yi Meng tcp file transfer and Automatic Update system introduction (TCP File transfer) (iii)
Address: https://item.taobao.com/item.htm?spm=686.1000925.0.0.AjdBGP&id=537538462790
Demo Program: HTTP://PAN.BAIDU.COM/S/1GEVFMCR
The idea of file uploading
1. Server-side
A directory is specified in the server-side configuration file, and all files uploaded by the client are saved in this directory.
But the files that come from the client are not saved directly in this directory, but now a subfolder is created in this directory and then saved in a subfolder.
Then the server side to receive the file, you need to know the name of the subfolder, this name is the client when uploading files, the relevant parameters are included.
As an example of this program, the server side specifies that the directory where the files are saved is the D drive. Then all the uploaded files will be saved in the D drive.
Client
The client uploads the file A.rar and tells the server-side A.rar to save it in the 20161201 folder.
The server will create a sub-folder with a name of 20161201 on the D drive, and then save the A.rar in this folder.
The client's code would be roughly the same:
Gets the local address of the file to be uploaded string filePath = Getfiletoopen ("Upload file"); Create a new file id string FileID = Fileidcreator.getnextfileid ( NetworkCommsDotNet.NetworkComms.NetworkIdentifier.ToString ()); Defines where the file is stored in the server (relative directory) string destfilepath = "20161201" + @ "\" + path.getfilename (filePath); Add file to file send manager sendfiledict.addsendfile (FileID, FilePath, destfilepath,appoutter.tcpconn);
After the server receives the message, the corresponding subdirectory is created and the file is saved according to the value in the Destfilepath.
qq:286275658
What are the advantages of this form?
In my document system, in this way, only the name of the subfolder is recorded in the fields of the database table.
Of course, subfolders can contain multiple files. For example, a document can contain multiple attachments.
Client, you can get all the files in this folder based on the subfolder name of an official document.
Yi Meng tcp file transfer and Automatic Update system introduction (TCP File transfer) (iii)