private void dragUpdateLabel_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] filePath = (string[])e.Data.GetData(DataFormats.FileDrop); String path = Properties.Settings.Default.mcPath; path = path.Substring(0, path.Length - 18); Update.updateFile(filePath[0], path); } }
void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { if (e.Cancelled) MessageBox.Show(this.Resources["downloadCanceled"].ToString()); else { MessageBox.Show(this.Resources["downloadFinish"].ToString()); if (download.Contains("MCLauncherW.exe")) { string filename = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "killmyself.bat"); using (StreamWriter bat = File.CreateText(filename)) { // 自升级 bat.WriteLine(string.Format(@" @echo off :selfkill attrib -a -r -s -h ""{0}"" del ""{0}"" if exist ""{0}"" goto selfkill copy /y ""new.exe"" ""{0}"" del ""new.exe"" ""{0}"" del %0 ", AppDomain.CurrentDomain.FriendlyName)); } // 启动自删除批处理文件 ProcessStartInfo info = new ProcessStartInfo(filename); info.WindowStyle = ProcessWindowStyle.Hidden; Process.Start(info); // 强制关闭当前进程 Environment.Exit(0); } else { String path = Properties.Settings.Default.mcPath; path = path.Substring(0, path.Length - 18); Update.updateFile("update.zip", path); Properties.Settings.Default.minecraftVersion = MainWindow.newMinecraftVersion; Properties.Settings.Default.Save(); } } this.win.Show(); this.Close(); }