Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# unzip all archive files inside directory

        /// <summary>
        /// Unzip files using Extract to directory method
        /// </summary>
        /// <param name="zipPath">complete path and zipfilename</param>
        /// <param name="extractedPath">extracted files desitnation path</param>
        public static void UnZipToDir(string zipPath, string extractedPath)
        {
            try
            {
                // ZipFile.ExtractToDirectory(zipPath, extractedPath);
                Directory.GetFiles(zipPath, "*.zip", SearchOption.AllDirectories).ToList()
                .ForEach(zipFilePath =>
                {
                    var currentZipPath = Path.Combine(extractedPath, Path.GetFileNameWithoutExtension(zipFilePath));

                    //Inside DLL that will just create the directory if not exist
                    Util_Directory.CreateDirectory(currentZipPath);

                    System.IO.Compression.ZipFile.ExtractToDirectory(zipFilePath, currentZipPath);

                });
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
 
PREVIOUS NEXT
Tagged: #unzip #archive #files #directory
ADD COMMENT
Topic
Name
6+3 =