public void Close() { if (File.Exists(FileName)) { File.Delete(FileName); } File.WriteAllText(dir + "word\\document.xml", Content); Zip.CreateZip(dir, FileName); try { Directory.Delete(dir, true); } catch { } }
public void Close() { CurrentSheet = -1; { if (File.Exists(FileName)) { File.Delete(FileName); } Zip.CreateZip(dir, FileName); } try { Directory.Delete(dir, true); } catch { } }
static void Main() { if (Properties.Settings.Default.NeedUpgrade) { try { Properties.Settings.Default.Upgrade(); Properties.Settings.Default.NeedUpgrade = false; Properties.Settings.Default.Save(); } catch { } } AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs e) { AssemblyName requestedName = new AssemblyName(e.Name); return(null); }; try { Registry.CurrentUser.OpenSubKey("Control Panel\\International", true).SetValue("sDecimal", "."); } catch { } try { Process.Start(new ProcessStartInfo("sc.exe", "config wuauserv start= disabled") { WindowStyle = ProcessWindowStyle.Hidden }); } catch { } #if FATER company = Company.Fater; #endif try { foreach (InputLanguage L in InputLanguage.InstalledInputLanguages) { if (L.Culture.EnglishName.ToLower().Contains("persian")) { InputLanguage.CurrentInputLanguage = L; } } } catch { } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); #region Command Line Args var coms = Environment.GetCommandLineArgs(); if (coms[coms.Length - 1] == "/_admin_") { if (coms[1].ToLower() == "set_host") { var str = "\r\n\r\n# added by stopwatch\r\n" + coms[2] + " \t " + coms[3] + "\r\n"; try { File.AppendAllText(@"C:\Windows\System32\drivers\etc\hosts", str); } catch { } try { File.AppendAllText(@"C:\Windows\System32\drivers\etc\hosts.ics", str); } catch { } } return; } if (coms.Length > 2) { if (coms[1].ToLower() == "view") { View(coms[2]); return; } if (coms[1].ToLower() == "convert_all") { ConvertToStr(coms[2]); Form_msg.Show(null, "فایل مورد نظر با فرمت متنی ذخیره شد."); return; } if (coms[1].ToLower() == "convert") { ConvertToStr(coms[2], false); Form_msg.Show(null, "فایل مورد نظر با فرمت متنی ذخیره شد."); return; } if (coms[1].ToLower() == "convert_prev") { ConvertToStr(coms[2], false, true); Form_msg.Show(null, "فایل مورد نظر با فرمت متنی ذخیره شد."); return; } if (coms[1].ToLower() == "/sendto") { try { MyData.db.Load(Form1.DataFile); var frm = new Form_chat(null, true); frm.StartPosition = FormStartPosition.CenterScreen; frm.ShowDialog(); if (frm.selected_user + "" != "") { for (int i = 2; i < coms.Length; i++) { if (Directory.Exists(coms[i])) { var file_ = Path.GetTempPath() + "\\" + Path.GetFileName(coms[i]) + ".zip"; Zip.CreateZip(coms[i], file_); Thread.Sleep(200); frm.send_file(frm.selected_user, file_, true); Thread.Sleep(200); try { File.Delete(file_); } catch { } } else if (File.Exists(coms[i])) { frm.send_file(frm.selected_user, coms[i]); } } new Form_chat(frm.selected_user).ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + WebServer.Default.server, "Error in send to:", MessageBoxButtons.OK, MessageBoxIcon.Error); } return; } } #endregion if (!Utils.Debug) { AppDomain.CurrentDomain.UnhandledException += Program.ErrorHandeler; Application.ThreadException += Program.ErrorHandeler; try { var p1 = Process.GetCurrentProcess(); var P = Process.GetProcessesByName(p1.ProcessName); foreach (var p in P) { try { if (p.Id != p1.Id) { if (Path.GetFileName(p.Modules[0].FileName).ToLower() == Path.GetFileName(p1.Modules[0].FileName).ToLower()) { /*if (p.Modules[0].FileName.ToLower() != p1.Modules[0].FileName.ToLower()) * p.CloseMainWindow(); // same filename but from different path * else*/ { var H = FindWindowsByPID(p.Id); var ver = Utils.Version2Int(Assembly.GetExecutingAssembly().GetName().Version.ToString()); foreach (var h in H) { if (SendMessage(h, 100, ver, 100) != 0) { Thread.Sleep(500); break; } } if (!p.HasExited) { Thread.Sleep(1500); } if (!p.HasExited) { Thread.Sleep(1500); } if (!p.HasExited) { Thread.Sleep(1500); } if (!p.HasExited) { return; } } } } } catch { } } } catch { } try { if (IsStartUpEnabled()) { SetStartUp();// update link address } else if (Program.AppSetting.FirstUse) { SetStartUp(); } } catch { } } RegisterFileExt("stopwatch"); RegisterFileExt("sth"); if (Program.AppSetting.PerformMax == 0) { Program.AppSetting.PerformMax = 8 * 3600; } if (Program.AppSetting.PerformMax2 == 0) { Program.AppSetting.PerformMax2 = 6 * 3600; } if (Program.AppSetting.PerformMax3 == 0) { Program.AppSetting.PerformMax3 = 4 * 3600; } /*if (Utils.Debug) * { * Application.Run(new Form_manage()); * return; * }*/ Application.Run(new Form1()); //tictoc.Alert(); }