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:// ...
随机推荐
- Haproxy均衡负载部署和配置文件详解
HAproxy均衡负载部署和配置文件详解 HAProxy提供高可用性.负载均衡以及基于TCP和HTTP应用的代理,支持虚拟主机,它是免费.快速并且可靠的一种解决方案.根据官方数据,其最高极限支持10G ...
- 297. Serialize and Deserialize Binary Tree
题目: Serialization is the process of converting a data structure or object into a sequence of bits so ...
- android学习系列:jercy——AI3 的博客
[android学习之十七]——特色功能2:桌面组件(快捷方式,实时文件夹) 二.桌面组件 1.快捷方式 Android手机上得快捷方式的意思可以以我们实际PC机器上程序的快捷方式来理解.而andro ...
- 在windows上配置jdk环境
下载和安装的java jdk的步骤此处就忽略了.就从配置jdk配置开始说起: 安装完JDK后配置环境变量 计算机→属性→高级系统设置→高级→环境变量 系统变量→新建 JAVA_HOME 变量 . 变 ...
- 利用ExtJS导出Excel
Ext.ns("Msp.Component"); //config = { // fileName : "净值及头寸核对", // exportDate : & ...
- Eclipse下运行Maven项目提示缺少maven-resources-plugin:2.4.3
将一个手动创建的Maven项目(命令行下可正常运行)导入到Eclipse中,运行时提示这样的错误信息:[ERROR] Plugin org.apache.maven.plugins:maven-res ...
- 在linux系统下检查postgresql数据库安装,登录数据库及简单的查看数据库
1. 检查Linux系统是否安装数据库 首先查看自己的系统是否安装了postgresql数据库命令如下: rpm -qa | grep postgresql 如果没有显示查询结果(如下图所示)说 ...
- 1141. RSA Attack(RSA)
1141 越来越喜欢数论了 很有意思 先看个RSA的介绍 RSA算法是一种非对称密码算法,所谓非对称,就是指该算法需要一对密钥,使用其中一个加密,则需要用另一个才能解密. RSA的算法涉及三个参数,n ...
- 邦定lua函数到C里做为回调
1, int ref = luaL_ref(L, LUA_REGISTRYINDEX); //把栈顶的obj 存在lua的表里面,返回一个唯一的引用,(栈顶的obj被自动清除),,(这个引用作为回 ...
- 结构体 lock_t;
typedef struct lock_struct lock_t; //利用typedef定义一个变量的类型 /** Lock struct */ struct lock_struct { trx_ ...