lol a guest Nov 19th, 2014 1,024 Never a guest1,024Never

Not a member of Pastebin yet? Sign Up , it unlocks many cool features!

rawdownloadcloneembedreportprint C# 1.70 KB /// <summary> /// Checks if all files needed exists /// </summary> private void RequiredFilesExistCheck ( ) { //Required files needed to run program string [ ] requiredFiles = { "test.jpg" , "test1.jpg" } ; //Stores files in directory List < string > filesInDirectory = new List < string > { } ; //Directory path of where files are stored string directoryPath = @"C:\Users\" + username + @"\AppData\Local\Temp\NGStatEditor" ; //Gets all files in the directory var getFiles = System. IO . Directory . GetFiles ( directoryPath ) ; //Gets files in directory foreach ( var myFiles in getFiles ) { //Gets file names from array foreach ( var myRequiredFiles in requiredFiles ) { //Removes directory path, only keeps file name var files = myFiles . Remove ( 0 , directoryPath . Length + 1 ) ; //Add files in directory to list filesInDirectory . Add ( files ) ; } } //Compares requiredFiles and filesInDirectory to check if all files needed exist if ( requiredFiles . All ( filesInDirectory . Contains ) ) { MessageBox . Show ( "True" ) ; userHasFiles = true ; filesInDirectory . Clear ( ) ; } else { MessageBox . Show ( "False" ) ; userHasFiles = false ; } } } }

RAW Paste Data

/// <summary> /// Checks if all files needed exists /// </summary> private void RequiredFilesExistCheck() { //Required files needed to run program string[] requiredFiles = { "test.jpg", "test1.jpg" }; //Stores files in directory List<string> filesInDirectory = new List<string> { }; //Directory path of where files are stored string directoryPath = @"C:\Users\" + username + @"\AppData\Local\Temp\NGStatEditor"; //Gets all files in the directory var getFiles = System.IO.Directory.GetFiles(directoryPath); //Gets files in directory foreach (var myFiles in getFiles) { //Gets file names from array foreach (var myRequiredFiles in requiredFiles) { //Removes directory path, only keeps file name var files = myFiles.Remove(0, directoryPath.Length + 1); //Add files in directory to list filesInDirectory.Add(files); } } //Compares requiredFiles and filesInDirectory to check if all files needed exist if (requiredFiles.All(filesInDirectory.Contains)) { MessageBox.Show("True"); userHasFiles = true; filesInDirectory.Clear(); } else { MessageBox.Show("False"); userHasFiles = false; } } } }