Auto Updating the exe from a network location when application starts z
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
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的更多相关文章
- win7 、2008 提示Error 1606 Could Not Access Network Location %SystemDrive%/inetpub/wwwroot/ 的错误解决方法
在安装控件过程中出现提示Error 1606 Could Not Access Network Location %SystemDrive%/inetpub/wwwroot/ 的错误解决方法 1. 点 ...
- 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 ...
- Eureka启动报错:Failed to load property source from location 'classpath:/application.yml'
原因: 将application.yml添加到classpath时, 由于变更了application.yml的编码格式(或许也改变了些代码内容), 而target内的yml文件没有实时更新, 从而导 ...
- Error 1606 Could Not Access Network Location %SystemDrive%/inetpub/wwwroot/ 的错误解决方法
在卸载或者重安装Infragistics NetAdvantage时候提示如标题的错误 win7下 1.打开注册表 Regedit 2.找到HKEY_LOCAL_MACHINE/SOFTWARE/Mi ...
- 安装、卸载 node.js出错 Could not access network location *:\node.js\ 出错
上周五,WIN10自动更新系统,导致我的node.js 和 Gradle 还有解压的winRAR都不能用!!!可恶 自动更新!!可恶啊!!! 然后我想把node.js重新卸载了再安装,结果 很慌很慌, ...
- 排错技能:任务管理器中追踪某w3wp.exe是哪个IIS站点的application pool
如果Windows的任务管理器中发现某个w3wp.exe占用了100%CPU,那我们就要揪出这是那个网站的application pool在作怪, 首先,每个站点一定要单独使用各自的applicati ...
- springboot启动报异常,Failed to load property source from location 'classpath:/application.yml'
学习springboot,在启动时抛出下图异常 往下看异常信息,找到异常的具体位置 找到application.yml文件的对应位置,发现params配置前面多了空格 去掉空格重新启动,可以了 写代码 ...
- 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 ...
- Win7系统服务优化完全攻略
前文提到Windows系统启动的原理,其中加载各项系统服务是影响系统启动时间的重要因素,之前软媒在Win7之家(http://www.win7china.com/)和Vista之家(http:// ...
随机推荐
- Sublime Text 新建文件可选类型的模版插件: SublimeTmpl
安装方法: 1.Ctrl+Shift+P打开控制台, 2.输入IP安装插件 3.输入tmpl 回车安装 编辑模版在:SublimeTmpl\templates"文件夹修改 其他情况: htt ...
- Android 时间轴
最近开发的app中要用到时间轴这东西,需要实现的效果如下: 想想这个东西应该可以用listview实现吧.然后最近就模拟着去写了: 首先写 listview的item的布局: listview_it ...
- git源码推荐
http://git.oschina.net/explore/monthly http://git.oschina.net/juapk/spring-wind http://git.oschina.n ...
- USACO Section 3.2: Stringsobits
这题看了网上的答案的.还是很巧妙的 /* ID: yingzho1 LANG: C++ TASK: kimbits */ #include <iostream> #include < ...
- javascript 网络是否连接的几种方案
js 网络是否连接的几种方案 1.通过html5的新属性: window.onload = function () { var isOnLine = navigator.on ...
- 短信发送AZDG加密算法
public static string passport_encrypt(string txt, string key) { // 使用随机数发生器产生 ...
- Android 第三方应用接入微信平台(1)
关键字:微信开放平台 Android第三方应用接入微信 微信平台开放后倒是挺火的,许多第三方应用都想试下接入微信这个平台, 毕竟可以利用微信建立起来的关系链来拓展自己的应用还是挺不错的,可 以节约 ...
- 线程中无法实例化spring注入的服务的解决办法
问题描述 在Java Web应用中采用多线程处理数据,发现Spring注入的服务一直报NullPointerException.使用注解式的声明@Resource和XML配置的bean声明,都报空指针 ...
- Machine Learning for hackers读书笔记(五)回归模型:预测网页访问量
线性回归函数 model<-lm(Weight~Height,data=?) coef(model):得到回归直线的截距 predict(model):预测 residuals(model):残 ...
- 51nod1189 阶乘分数
(x-n!)(y-n!)=n!2 ans=t[n]+1.t表示的是n!2的小于n!的约数个数.n!2=p1a1*p2a2*p3a3...t[n]=(a1+1)*(a2+1)...-1 /2; 2对于n ...