Пример #1
0
        public static void Decompress(FileInfo fi, string extractDirectory)
        {
            UnzipDataDataContext db = new UnzipDataDataContext();
            string compressedFile   = fi.DirectoryName + fi.Name;
            string fileName         = fi.Name.Replace(".zip", "");
            string directory        = fi.DirectoryName + fileName;


            ZipFileName zipname = new ZipFileName();

            var found = from name in db.ZipFileNames
                        where name.ZipFileName1 == fileName & name.Extracted == true
                        select name;

            zipname.ZipFileName1 = fileName;
            if (found.Count() == 0)
            {
                try
                {
                    Directory.CreateDirectory(directory);
                    ZipFile.ExtractToDirectory(compressedFile, directory);
                    zipname.Extracted = true;
                    File.Delete(compressedFile);

                    Console.WriteLine("Decompressed: {0}", fi.Name);
                }
                catch (Exception e)
                {
                    zipname.Extracted = false;
                    Console.WriteLine("Couldn't decompress: {0} Error: {1}", fi.Name, e.ToString());
                }
                db.ZipFileNames.InsertOnSubmit(zipname);
                db.SubmitChanges();
            }
            else
            {
                Console.WriteLine("nothing added because its already been found");
            }
        }
Пример #2
0
        public static void Decompress(FileInfo fi, string extractDirectory)
        {
            UnzipDataDataContext db = new UnzipDataDataContext();
            string compressedFile = fi.DirectoryName + fi.Name;
            string fileName = fi.Name.Replace(".zip","");
            string directory = fi.DirectoryName + fileName;

            ZipFileName zipname = new ZipFileName();

            var found = from name in db.ZipFileNames
                        where name.ZipFileName1 == fileName & name.Extracted == true
                        select name;
            zipname.ZipFileName1 = fileName;
            if (found.Count() == 0)
            {

                try
                {
                    Directory.CreateDirectory(directory);
                    ZipFile.ExtractToDirectory(compressedFile, directory);
                    zipname.Extracted = true;
                    File.Delete(compressedFile);

                    Console.WriteLine("Decompressed: {0}", fi.Name);

                }
                catch (Exception e)
                {
                    zipname.Extracted = false;
                    Console.WriteLine("Couldn't decompress: {0} Error: {1}", fi.Name, e.ToString());
                }
                db.ZipFileNames.InsertOnSubmit(zipname);
                db.SubmitChanges();
            }
            else {
                Console.WriteLine("nothing added because its already been found");
            }
        }
Пример #3
0
 partial void DeleteZipFileName(ZipFileName instance);
Пример #4
0
 partial void UpdateZipFileName(ZipFileName instance);
Пример #5
0
 partial void InsertZipFileName(ZipFileName instance);
Пример #6
0
 partial void DeleteZipFileName(ZipFileName instance);
Пример #7
0
 partial void UpdateZipFileName(ZipFileName instance);
Пример #8
0
 partial void InsertZipFileName(ZipFileName instance);