/// <summary> /// Event on click button "button" /// </summary> /// <param name="sender">Object</param> /// <param name="e">Event</param> private void button_Click(object sender, RoutedEventArgs e) { //Generate path for folder, file string app_data_path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string folder_path = app_data_path + "/" + MainWindow.FOLDER_NAME; string file_path = folder_path + "/" + MainWindow.CONFIG_FILE_NAME; MovieRepository movieRepo = new MovieRepository(); movieRepo.DeleteMovies(); dbhandler dbH = new dbhandler(); //create directory and file (close the file cause the processus doesn't stop himself) Directory.CreateDirectory(folder_path); var file = File.Create(file_path); file.Close(); // add config in findMyMovies.config new XDocument( new XElement("config", new XElement("path_movies", selected_path) ) ).Save(file_path); this.Close(); }
/// <summary> /// Launch choose folder windows it it's the first launch and initialize DB /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MetroWindow_Loaded(object sender, RoutedEventArgs e) { // get movie path in config file string appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string folderPath = appdataPath + "/" + MainWindow.FOLDER_NAME; string filePath = folderPath + "/" + MainWindow.CONFIG_FILE_NAME; string moviePath = ""; string ogFileNamePath = folderPath + "/originalFileName.txt"; if (!File.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } if (!File.Exists(ogFileNamePath)) { var file = File.Create(ogFileNamePath); file.Close(); } choosedirectory directoryClass = new choosedirectory(); if (File.Exists(filePath)) { moviePath = directoryClass.GetPathConfig(filePath, "/config/path_movies"); } // open the second form if it's the first launch if (moviePath == "") { directoryClass.ShowDialog(); directoryClass.Close(); } dbhandler FMDb = new dbhandler(); }