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 stringFilePath = Getfiletoopen ("Uploading Files"); //Create a new file ID stringFileID =Fileidcreator.getnextfileid (NetworkCommsDotNet.NetworkComms.NetworkIdentifier.ToString ()); //define where the file is stored in the server (relative directory) stringDestfilepath = "20161201" +@"\"+Path.getfilename (FilePath); //add a file to the file send managerSendfiledict.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)