static void Main() { //// {D19F100E-113F-4751-820C-FD5AF8D17A55} AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); string strLoc = Assembly.GetExecutingAssembly().Location; FileSystemInfo fileInfo = new FileInfo(strLoc); string sExeName = fileInfo.Name; bool bCreatedNew; if (false == LanguageTranslator.SetLanguage(System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName)) LanguageTranslator.SetLanguage("en"); mutex = new Mutex(true, "Global\\" + sExeName, out bCreatedNew); if (bCreatedNew) mutex.ReleaseMutex(); else { BasicInfo.LoadRegistryValues(); if (BasicInfo.SyncDirPath.Trim().Length != 0) { string argument = BasicInfo.SyncDirPath; System.Diagnostics.Process.Start(argument); } return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Create the events tables since they weren't here last time. // The tables are only created if they don't already exist so // it is safe to make this call every time to be sure they exist. DbHandler dbHandler = new DbHandler(); dbHandler.CreatedNewDatabase(); dbHandler.CreateEventsTable(); dbHandler.CreateIssueTable(); // Clear any local events since the code will search for any local // changes and create events for them. dbHandler.ClearLocalEvents(); dbHandler = null; frmLogin loginForm = new frmLogin(); bool showLogin = loginForm.showLogin; if (showLogin) { Application.Run(loginForm); } else { loginForm.Login(); Application.Run(); } }
private void CheckAndCreateSyncDirectory() { DbHandler dbHandler = new DbHandler(); bool isDbCreateNew = false; bool isDirectoryExists = false; if (BasicInfo.SyncDirPath.Trim().Length != 0) isDirectoryExists = System.IO.Directory.Exists(BasicInfo.SyncDirPath); string dirName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\" + AboutBox.AssemblyTitle; //Modified code to fixed issue # 1417 Checking first is directory exists or not if (!isDirectoryExists) { if (showLogin == false && !isDirectoryExists) { DialogResult checkDir; string message = LanguageTranslator.GetValue("ExpectedLocation") + Environment.NewLine + BasicInfo.SyncDirPath + ". " + Environment.NewLine + Environment.NewLine + LanguageTranslator.GetValue("FolderMoved") + Environment.NewLine + Environment.NewLine + LanguageTranslator.GetValue("ClickNoExit") + Environment.NewLine + Environment.NewLine + LanguageTranslator.GetValue("ClickYesRestore"); string caption = LanguageTranslator.GetValue("CaptionFileMissingDialog"); MessageBoxButtons buttons = MessageBoxButtons.YesNo; MessageBoxDefaultButton defaultbutton = MessageBoxDefaultButton.Button2; checkDir = MessageBox.Show(message, caption, buttons, MessageBoxIcon.None, defaultbutton); if (checkDir == DialogResult.Yes) { System.IO.Directory.CreateDirectory(dirName); //Adding Code to change folder icon folderIcon(dirName); BasicInfo.IsInitialSync = true; BasicInfo.SyncDirPath = dirName; dbHandler.DeleteDb(); dbHandler.CreatedNewDatabase(); dbHandler.OpenConnection(); } else { System.Environment.Exit(0); } } else { isDbCreateNew = dbHandler.CreatedNewDatabase(); if (!isDirectoryExists) { System.IO.Directory.CreateDirectory(dirName); //Adding Code to change folder icon folderIcon(dirName); } BasicInfo.IsInitialSync = true; // Always set the BasicInfo.SyncDirPath value. BasicInfo.SyncDirPath = dirName; } } else { //if directory exits checking whether we have new database or not isDbCreateNew = dbHandler.CreatedNewDatabase(); BasicInfo.AutoSync = true; BasicInfo.SyncDirPath = dirName; } System.IO.Directory.SetCurrentDirectory(BasicInfo.SyncDirPath); }