コード例 #1
0
        /// <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();
        }