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
Collapse | Copy Codeusing 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:// ...
随机推荐
- android-exploitme(四):参数篡改
今天我们来测试请求中参数的篡改,这个在web安全测试中是常用的,拦截请求包,修改参数,提交 1. 首先我们需要启动模拟器,并使用本机的代理(加上参数-partition-size的目的是为了可以往a ...
- ubuntu下搭建cocos2dx编程环境-上
这大半年一直在开发flash游戏,用到的编程语言是actionscript和c++.所以这次公司决定开发手游端的话,C++不是很生疏,这是个好消息.坏消息是由于现在网页游戏还没有上线,所以公司 ...
- Oracle ->> TRUNC, ROUND, CEIL, FLOOR
), ), CEIL(10.01), FLOOR(10.9999) FROM dual; 结果: TRUNC是直接截断小数位 ROUND是四舍五入 CEIL和FLOOR则是和SQL SERVER一样返 ...
- Lua的协程(coroutine)
-------------------------------------------------------------------------------- -- 不携带参数 ---------- ...
- android学习系列:jercy——AI3 的博客
[android学习之十七]——特色功能2:桌面组件(快捷方式,实时文件夹) 二.桌面组件 1.快捷方式 Android手机上得快捷方式的意思可以以我们实际PC机器上程序的快捷方式来理解.而andro ...
- node-odata: 基于 NodeJS 的 REST 框架
该开源项目目前已被 OData 官网 (odata.org)收录 关于 node-odata node-odata 可以让你轻松创建 REST API, 并能使用 OData 协议的格式进行数据的查询 ...
- [置顶] 炎炎夏日,给你一次极爽的开发体验!——统一开发环境功能升级优化,正式上线V2.0!
作为中国移动应用运行托管平台(MM应用引擎)的开发部署工具,统一开发环境(UDE)在原HTML5跨平台开发功能基础上优化升级,新增跨平台编译(Android/iOS)和云端托管服务,正式上线2.0版本 ...
- Android技术面试整理
前19题为常考题目!! 1.Android的四大组件是哪些,它们的作用? 2.请介绍下Android中常用的五种布局. 3.android中的动画有哪几类,它们的特点和区别是什么 4.android ...
- awk文本处理知识汇总
参考资料:http://man.linuxde.net/awk http://www.cnblogs.com/chengmo/archive/2013/01/17/2865479.html http: ...
- BZOJ 2752 高速公路(road)(线段树)
题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=2752 题意:给出一个数列A,维护两种操作: (1)将区间[L,R]之内的所有数字增加de ...