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
{
static void Main(string[] args)
{
//updatepath is the location where I upload updated exe
string UpdatePath = @"\\testserver\Art\ship it\Shipit.exe";
//applocation is the location from where this console app runs.It will also be the location where the new file will be saved
string AppLocation = Directory.GetCurrentDirectory() + @"\shipit.exe"; try
{
FileInfo info1 = null;
FileInfo info2 = null;
if (File.Exists(UpdatePath))
{
//If there is a file in the update location info1 will 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 (File.Exists(location))
{
try
{
Process.Start(location);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message); return;
}
}
else
{ }
} }
}

The  function executeApp() will help in starting the exe from the location .thus it makes sure that the user always use the latest exe

 
 
 

Auto Updating the exe from a network location when application starts z的更多相关文章

  1. win7 、2008 提示Error 1606 Could Not Access Network Location %SystemDrive%/inetpub/wwwroot/ 的错误解决方法

    在安装控件过程中出现提示Error 1606 Could Not Access Network Location %SystemDrive%/inetpub/wwwroot/ 的错误解决方法 1. 点 ...

  2. java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.yml'

    java.lang.IllegalStateException: Failed to load property source from location 'classpath:/applicatio ...

  3. Eureka启动报错:Failed to load property source from location 'classpath:/application.yml'

    原因: 将application.yml添加到classpath时, 由于变更了application.yml的编码格式(或许也改变了些代码内容), 而target内的yml文件没有实时更新, 从而导 ...

  4. Error 1606 Could Not Access Network Location %SystemDrive%/inetpub/wwwroot/ 的错误解决方法

    在卸载或者重安装Infragistics NetAdvantage时候提示如标题的错误 win7下 1.打开注册表 Regedit 2.找到HKEY_LOCAL_MACHINE/SOFTWARE/Mi ...

  5. 安装、卸载 node.js出错 Could not access network location *:\node.js\ 出错

    上周五,WIN10自动更新系统,导致我的node.js 和 Gradle 还有解压的winRAR都不能用!!!可恶 自动更新!!可恶啊!!! 然后我想把node.js重新卸载了再安装,结果 很慌很慌, ...

  6. 排错技能:任务管理器中追踪某w3wp.exe是哪个IIS站点的application pool

    如果Windows的任务管理器中发现某个w3wp.exe占用了100%CPU,那我们就要揪出这是那个网站的application pool在作怪, 首先,每个站点一定要单独使用各自的applicati ...

  7. springboot启动报异常,Failed to load property source from location 'classpath:/application.yml'

    学习springboot,在启动时抛出下图异常 往下看异常信息,找到异常的具体位置 找到application.yml文件的对应位置,发现params配置前面多了空格 去掉空格重新启动,可以了 写代码 ...

  8. Springboot - java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.yml'

    Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning a simple key in 'reader', lin ...

  9. Win7系统服务优化完全攻略

      前文提到Windows系统启动的原理,其中加载各项系统服务是影响系统启动时间的重要因素,之前软媒在Win7之家(http://www.win7china.com/)和Vista之家(http:// ...

随机推荐

  1. BufferedReader方法-----Scanner方法

    import java.io.*; import java.util.Scanner; public class C { public static void main(String []args) ...

  2. Hadoop HDFS文件系统通过java FileSystem 实现上传下载等

    package linlintest; import java.io.File; import java.io.FileOutputStream; import java.io.IOException ...

  3. OpenGL基础渲染

    客户端-服务器 客户端是存储在CPU存储器中的,并且在应用程序中执行(或者驱动程序),驱动程序将渲染命令和数据组合起来,发动到服务器执行.服务器和客户机在功能上是异步的,他们是各自独立的软件模块或者硬 ...

  4. Android开发效率—Eclipse快捷键

    很多过去使用Visual Studio开发软件的网友可能不熟悉Java开发环境,今天Android开发网告诉大家一些提高Android开发效率的Eclipse快捷键,可以有效率的帮助我们管理代码和减少 ...

  5. JWFD开源项目官方网站预览

    自己做的...感觉还比较正规哈....JWFD开源项目还是需要一个官方网站的...

  6. MTK6577 Android源代码目录

    MTK6577 Android源代码目录 1.     MTKAndroid4.0 源代码目录 (1)  makeMtk 整个工程编译或是构建(make/build)的入口. (2)  abi 应用程 ...

  7. C语言输出当前日期和时间

    #include <stdio.h> #include <time.h> char* asctime2(const struct tm *timeptr) { static c ...

  8. [HIHO1041]国庆出游(DFS, bitset)

    题目链接:http://hihocoder.com/problemset/problem/1041 学会了用C++的bitset哈,可喜可贺.以后遇到超过64位想用位来表示状态就不愁了哈. 这题用bi ...

  9. python中的 @ 修饰符

    今天学习廖老师的python教程,碰到了修饰符'@',不太了解,查看了下官方文档. 简单的整理下: @dec2 @dec1 def func(arg1, arg2, ...): pass 等价于 de ...

  10. HDFS的体系结构和操作

    1.对hdfs操作的命令格式是hadoop fs 1.1 -ls <path> 表示对hdfs下一级目录的查看 1.2 -lsr <path> 表示对hdfs目录的递归查看 1 ...