/****************************** * 说明:公共类 * 创建人:龚宇超 * 创建日期:2018-02-09 * 修改人: * 修改日期: * 修改备注: * 版本:1.0.0.0 ******************************/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Diagnostics; using System.Windows.Forms; namespace Lskj.AutoUpdate { /// /// 公共类 /// public class CommonUnitity { /// /// 应用程序启动目录 /// public static string SystemBinUrl = AppDomain.CurrentDomain.BaseDirectory; /// /// 说明:重启应用 /// 创建人:龚宇超 /// 创建日期:2018-02-23 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// public static void RestartApplication() { Process.Start(Path.Combine(Application.ExecutablePath, ConstModel.LS_ERP_EXE)); Environment.Exit(0); } /// /// 说明:获取文件夹路径 /// 创建人:龚宇超 /// 创建日期:2018-02-23 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The file. /// System.String. public static string GetFolderUrl(DownloadFileInfo file) { try { string folderPathUrl = string.Empty; int folderPathPoint = file.DownloadUrl.IndexOf("/", 15) + 1; string filepathstring = file.DownloadUrl.Substring(folderPathPoint); if (filepathstring.IndexOf("/") != -1) { string[] ExeGroup = filepathstring.Split('/'); for (int i = 0; i < ExeGroup.Length - 1; i++) { folderPathUrl += "\\" + ExeGroup[i]; } if (!Directory.Exists(SystemBinUrl + ConstModel.TEMP_FOLDER_NAME + folderPathUrl)) { Directory.CreateDirectory(SystemBinUrl + ConstModel.TEMP_FOLDER_NAME + folderPathUrl); } if (!Directory.Exists(SystemBinUrl + ConstModel.Batch_FOLDER_NAME)) { Directory.CreateDirectory(SystemBinUrl + ConstModel.Batch_FOLDER_NAME); } } return folderPathUrl; } catch (Exception ex) { MessageBox.Show("获取文件夹路径失败:"+ file.DownloadUrl + "\r\n" + ex.Message); return ""; } } } }