private void CreateMainFolder() { Directory.CreateDirectory($@"{App.MainPath}\File Protect"); File.Create($@"{App.MainPath}\File Protect\.log").Close(); Logs.WriteLog($"First application startup"); Logs.WriteLog($"\"{App.MainPath}\\File Protect\" has been created!"); Logs.WriteLog($"\"{App.MainPath}\\File Protect\\.log\" has been created!"); View.CreatePass createPass = new View.CreatePass(); Logs.WriteLog("Creating password window has been opened!"); createPass.ShowDialog(); }
public MainViewModel() { try { if (!Directory.Exists($"{App.MainPath}")) { Directory.CreateDirectory($"{App.MainPath}"); CreateMainFolder(); } else { if (!Directory.Exists($@"{App.MainPath}\File Protect")) { CreateMainFolder(); } else { if (!File.Exists($@"{App.MainPath}\File Protect\.log")) { File.Create($@"{App.MainPath}\File Protect\.log").Close(); Logs.WriteLog($"\"{App.MainPath}\\File Protect\\.log\" has been created!"); } if (!File.Exists($@"{App.MainPath}\File Protect\appsettings.json")) { Logs.WriteLog("Application starts working!"); View.CreatePass createPass = new View.CreatePass(); Logs.WriteLog("Creating password window has been opened!"); createPass.ShowDialog(); } else { Logs.WriteLog("Application starts working!"); View.PasswordReq passwordReq = new View.PasswordReq(); Logs.WriteLog("Password request window has been opened!"); passwordReq.ShowDialog(); } } } mainPage = new Pages.Main(); cryptPage = new Pages.Crypt(); decryptPage = new Pages.Decrypt(); settingsPage = new Pages.Settings(); Logs.WriteLog("Pages has been initialized"); FrameOpacity = 1; currentPage = mainPage; if (Directory.Exists($"{Environment.CurrentDirectory}\\UPDATE")) { string[] files = Directory.GetFiles($"{Environment.CurrentDirectory}\\UPDATE"); foreach (string file in files) { if (File.Exists($"{Environment.CurrentDirectory}\\{Path.GetFileName(file)}")) { File.Delete($"{Environment.CurrentDirectory}\\{Path.GetFileName(file)}"); } File.Move(file, $"{Environment.CurrentDirectory}\\{Path.GetFileName(file)}"); } Directory.Delete($"{Environment.CurrentDirectory}\\UPDATE"); } if (App.Settings == null || App.Settings.CheckUpdates) { UpdateChecker uc = new UpdateChecker(); uc.ShowDialog(); } Logs.WriteLog("Main page has been selected"); } catch (Exception ex) { ErrorWriter.WriteError(ex); } }