Example #1
0
        /// <summary>
        /// Method:         dsCabFile
        /// Description:    This method is used to handle various functions like list a cab file contents,
        ///                 create a cab file from a directory containing files, or even extract files from
        ///                 a cab file.
        /// </summary>
        /// <param name="cabFileName"></param>
        /// <param name="cabFileLocation"></param>
        /// <param name="cabFlag"></param>
        public static void dsCabFile(string cabFileName, string cabFileLocation, int cabFlag)
        {
            if (cabFlag == 0)
            {
                Program.copyrightBanner();
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("The cabinet file {0} has the following files embedded within it: ", cabFileName);
                CabInfo CabFile = new CabInfo(cabFileName);
                Console.WriteLine("\nCab FileName" + "\t" + "Cab FileSize (KB)");
                foreach (CabFileInfo CabIndvFile in CabFile.GetFiles())
                {
                    Console.WriteLine(CabIndvFile.Name + "\t" + CabIndvFile.Length);
                }
                Console.ResetColor();
            }

            else if (cabFlag == 1)
            {
                Program.copyrightBanner();
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Cab File {0} is being created. The following files are being added now: \n", cabFileName);
                ArchiveInfo cabFile = CompressedFileType(cabFileName);
                cabFile.Pack(cabFileLocation, true, CompressionLevel.Max, cabProgress);
                Console.WriteLine("\nThe Cab File {0} is successfully created.", cabFileName);
                Console.ResetColor();
            }

            else if (cabFlag == 2)
            {
                Program.copyrightBanner();
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Cab File {0} is being extracted. The following files are being extracted now: \n", cabFileName);
                ArchiveInfo cabFile = CompressedFileType(cabFileName);
                cabFile.Unpack(cabFileLocation, cabProgress);
                Console.WriteLine("\nThe cab file {0} is extracted to {1}", cabFileName, cabFileLocation);
                Console.ResetColor();
            }
        }
Example #2
0
 public static void Main(string[] args)
 {
     try
     {
         if (args.Length == 3 && args[0].ToUpperInvariant() == "/P")
         {
             ArchiveInfo a = GetArchive(args[1]);
             a.Pack(args[2], true, CompressionLevel.Max, ProgressHandler);
         }
         else if (args.Length == 3 && args[0].ToUpperInvariant() == "/U")
         {
             ArchiveInfo a = GetArchive(args[1]);
             a.Unpack(args[2], ProgressHandler);
         }
         else
         {
             Usage(Console.Out);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
Example #3
0
 public static void Pack(this ArchiveInfo o, string sourceDirectory, IPackStreamContext ipackstreamcontext)
 {
     o.Pack(sourceDirectory, false, CompressionLevel.Max, null);
 }