Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Collections.Generic;
- using com.wms.dirs;
- using com.wms.files;
- /*
- You'll first need to compile dirs.dll from com_wms_dirs.cs. That source code is found
- in c:\csdev\library\dirs_dll\, or at these URLs:
- + https://gist.github.com/kyrathasoft/aca4a458ce58edb05f4476a8186cae33
- + https://pastebin.com/C42PBvgM
- To compile dirs.dll use: csc /t:library /out:dirs.dll com_wms_dirs.cs
- Then, to compile the cull.cs source code file, which should be in the same
- directory as dirs.dll, use: csc /r:dirs.dll cull.cs
- To merge files.dll, dirs.dll, and cull.exe: ilmerge /t:exe cull.exe dirs.dll files.dll /ndebug /out:excull.exe
- */
- namespace ConsoleApplication {
- class Program
- {
- public static string PathC = @"c:\\csdev\\examples";
- public static string PathE = @"e:\\csdev\\examples";
- static void Main(string[] args)
- {
- Console.ForegroundColor = ConsoleColor.Yellow;
- Console.WriteLine("\n cull.exe");
- Console.ForegroundColor = ConsoleColor.White;
- string the_path = PathC;
- if(!Directory.Exists(the_path)){ the_path = PathE; }
- if(!Directory.Exists(the_path)){
- Console.WriteLine(" Fatal problem: couldn't locate directory c:\\csdev\\examples!");
- return;
- }
- string path_mod = the_path.Replace(@"\\", @"\");
- Console.WriteLine(" for culling DLL libraries and executables recursively from {0}", path_mod);
- try{
- int example_subdirs = Directory.GetDirectories(the_path, "*", SearchOption.TopDirectoryOnly).Length;
- Console.WriteLine(" Subdirectories found in {0}: {1}", path_mod, example_subdirs);
- int total_files = ClassDirs.GetDirectoryFileCount(the_path);
- Console.WriteLine(" Total files across examples (all directory levels): {0}", total_files);
- if(example_subdirs > 0){
- List<string> subdirs = ClassDirs.GetListOfSubdirectoryPaths(the_path);
- int deleted_executables = ClassFiles.DeleteAllFilesWithGivenExtension(subdirs, ".exe");
- int deleted_pdb = ClassFiles.DeleteAllFilesWithGivenExtension(subdirs, ".pdb");
- int deleted_partials = ClassFiles.DeleteAllFilesWithGivenExtension(subdirs, ".partial");
- int deleted_dlls = ClassFiles.DeleteAllFilesWithGivenExtension(subdirs, ".dll");
- Console.WriteLine(" *.exe files found and deleted: {0}", deleted_executables);
- Console.WriteLine(" *.pdb files found and deleted: {0}", deleted_pdb);
- Console.WriteLine(" *.partial files found and deleted: {0}", deleted_partials);
- Console.WriteLine(" *.dll files found and deleted: {0}", deleted_dlls);
- }
- }catch{}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement