/// <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(); }
/// <summary> /// Get path folder in config file and lauch directorySearch /// </summary> /// <returns>Files name</returns> public string[] GetAllFilename() { //get the choose directory form choosedirectory directoryClass = new choosedirectory(); //get path movie 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 = directoryClass.GetPathConfig(filePath, "/config/path_movies"); string ogFileNamePath = folderPath + "/originalFileName.txt"; if (!File.Exists(ogFileNamePath)) { File.Create(ogFileNamePath); } //get movie in directory and child directory List <string> filePaths = DirectorySearch(moviePath); DeleteMovies(filePaths, ogFileNamePath); return(filePaths.ToArray()); }//GetAllFilename