Auto Updating the EXE from a network location when application starts Z

Source: Internet
Author: User

Http://www.codeproject.com/Tips/869588/Auto-Updating-the-exe-from-a-network-location-when?msg=4992189#xx4992189xx

Using the Code

I wrote a simple console application in C # to accomplish this task

In the Program.cs itself I wrote the code to check updates and then executed the updated application

Collapse | Copy Code
Using System.Collections.Generic;Using System.Diagnostics;Using System.IO;Using System.Linq;Using System.Text;Using System.Threading.Tasks;Namespace shipitintro{Class Program {Staticvoid Main (String[] (args) {//Updatepath is the location where I upload updated exeString Updatepath =@"\\testserver\Art\ship It\shipit.exe ";//Applocation is the location from the where this console app runs. It'll also be the location where the new file would be savedString applocation = Directory.GetCurrentDirectory () +@"\shipit.exe ";try {FileInfo info1 =Null FileInfo Info2 =Nullif (file.exists (Updatepath)) {//If there is a file with the update location INFO1 would get the fileinfo of that file Info1 =New FileInfo (Updatepath); }if (file.exists (applocation)) {//If the EXE is already present in the aplocation get its information also Info2 =new FileInfo (applocation);} else {file.copy (Updatepath, applocation, true); Executeapp (applocation); return;} if (info1. LastWriteTime > Info2. LastWriteTime) {file.copy (Updatepath, applocation, true);}} catch (Exception ex) {Debug.WriteLine (ex. Message); } executeapp (Applocation); } static void Executeapp (string Location) {if (location) {file.exists catch (Exception ex) {Debug.WriteLine (ex. Message); return;} } else {}}}}            

The function Executeapp () would help in starting the EXE from the location. Thus it makes sure, the user always use th E Latest EXE

Auto Updating the EXE from a network location when application starts Z

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.