Calmly analyzed
Program description:
1. One web site
Purpose: A. Provides download sources (dll, exe, images... and so on... all the latest files)
B. what is that... well .... get a page and output data in xml format (using response. write output) the xml data must be reflected. The current version number, file name, and other information are shown in xml format as follows. (Of course, WebService can be used completely, but I personally think that xml is more professional and more economical)
2. Upgrade a program
Purpose: A. determines whether an upgrade is required.
B. download the file to be upgraded
C. Replace the old file with the new one.
3. The program you want to upgrade is not mentioned here. See the following details.
It is important to note that the Upgrade Program is an independent exe file, which is packaged with the main program and installed under the same directory. The first three programs complement each other to complete automatic upgrade and update. See the details.
The next step is the details. It's very cool. You're lucky. I have a bad mood today and I will give you details. (1, 2, 3... indicates the step)
Step 1: deny. At the same time, record the following attributes in the data table (the real name of the file [such as ABC.exe], the file, the path to the relative root path, and the file version number [with a version number (such as dll and exe) obtain the version number. If no version number is available (for example, jpg), obtain the MD5 value.])
Note: You can use Baidu "C # Get file version number" to obtain the relevant code.
Very embarrassing =! Here is a step to note: when the main program starts, the Upgrade Program (Process can do) has a problem Baidu "C # Start other applications"
Step 2: update the application request to generate the xml page (in fact, It Is An aspx, but the output content is in xml format, with response. write output), or you can use webservice to provide a method to return the data table (DataTable) mentioned in the first step ).
Step 3: The Upgrade Program translates xml content into datatable, and saves the time if webservice is used.
Step 4: the Upgrade Program traverses the datatable obtained in step 3 and obtains information about the old local file based on the "relative root path". If a local file exists, it obtains the version number or MD5 value, if there are no local files, versions, or MD5 values, the file must be updated (this information (DataRow) is saved to the queue (array, you know which files need to be downloaded.
Step 5: The Upgrade Program downloads files one by one to the (Temp directory) directory based on the queue obtained in step 1)
Step 6: Upgrade the program to shut down the main program Process (which can be done by the Process class). If there is a problem, you can Baidu "C # Stop other processes". In this way, you can keep the old file as needed, because they will no longer be occupied by other processes.
Step 7: Upgrade the program to move the files downloaded in step 3 to the corresponding directory one by one based on the "relative root path" field and replace the old files.
Step 8: after the work is completed, upgrade the program to start the main program (which can be done by the Process class). If there is a problem, Baidu "C # open other exe"
Step 9: no more.
Download can be used: httprequest and httpresponse. For details, see msdn. You can use them for resumable upload, real-time progress bar, and multi-thread download. You can also use WebClient. resumable upload and real-time progress cannot be obtained for the next file. The most important thing is that it is not professional.
The idea is here, and it cannot be wrong.
My name is green bean frog, and others like to call me SanYe. I haven't touched C/S for many years. I want to create a C/S project one day. My brother is in a bad mood today, because I am getting married, and the pressure is very high.
A: Sorry, I wrote code to implement it myself. I developed an upgrade program myself. It's not the one-click deployment technology that Microsoft once tried, later, I felt very embarrassed. I just published it to a site and clicked a button to install it. In the end, it was automatically updated when I was able to access the site. When I was not able to access the site, I executed the local code, you don't even know where it is installed on the client. It's embarrassing. Microsoft's one-click deployment technology is a floating cloud. I don't believe it, do you believe it or me? You must have believed it, haha .).