Implemented as LastnameDelete Deletes the files from the dir

Implemented as LastnameDelete. Deletes the files from the directory based on optional file filter LodgherDelete c:\\LFromDir (deletes all files from c:\\LFromDir to c:\\LToDir) LodgherDelete c:\\LFromDir*.txt (deletes all files with .txt extensions from c: \\LFromDir Grading rubric Perfect code with good documentation, All required exceptions handling, all required testing to check exceptions.

Solution

var exts = new[] { \".mp3\", \".jpg\" }; private void lastnameDelete(string folderName, string filesToExclude) { DirectoryInfo dir = new DirectoryInfo(folderName); foreach(FileInfo fi in dir.GetFiles()) { if(!fi.Name.Contains(filesToExclude)) { // System.Diagnostics.Debug.WriteLine(\"DELETING file \" + fi + \" because it does NOT contain \'\" + filesToExclude + \"\' \"); fi.Delete(); } else { // System.Diagnostics.Debug.WriteLine(\"SAVING file \" + fi + \" because it contains \'\" + filesToExclude + \"\' \"); } } foreach (DirectoryInfo di in dir.GetDirectories()) { if(!di.Name.Contains(filesToExclude)) { // System.Diagnostics.Debug.WriteLine(\"DELETING directory \" + di + \" because it does NOT contain \'\" + filesToExclude + \"\' \"); lastnameDelete(di.FullName, filesToExclude); di.Delete(); } else { // System.Diagnostics.Debug.WriteLine(\"SAVING directory \" + di + \" because it contains \'\" + filesToExclude + \"\' \"); } } }
 Implemented as LastnameDelete. Deletes the files from the directory based on optional file filter LodgherDelete c:\\LFromDir (deletes all files from c:\\LFromD

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site