PDA

View Full Version : سوال: فشرده سازی فایل ها



c-sharp_South
دوشنبه 27 شهریور 1391, 09:03 صبح
سلام :گریه:
دوستان اگه کسی در مورد فشرده سازی فایل ها سورس ها چیزه دیگه ای داره خواهش میکنم بزاره
یک هفته است دارم دنبالش میگردم ولی هنوز نتونستم به چیزی که میخوام برسم.
میخوام آدرس چند تا فایل رو داد و اون فایل ها در یک فایل ، فشرده بشوند.

مرسی :گریه::گریه:

ali_habibi1384
دوشنبه 27 شهریور 1391, 09:21 صبح
ذخيره چند فايل در يك فايل فشرده: (با VS2012)
using (ZipArchive newFile = ZipFile.Open(zipName, ZipArchiveMode.Create))
{
//Here are two hard-coded files that we will be adding to the zip
//file. If you don't have these files in your system, this will
//fail. Either create them or change the file names.
newFile.CreateEntryFromFile(@"C:\Temp\File1.txt", "File1.txt");
newFile.CreateEntryFromFile(@"C:\Temp\File2.txt", "File2.txt", CompressionLevel.Fastest);
}

SokooteShab1
دوشنبه 27 شهریور 1391, 09:54 صبح
فشرده کردن فایل مورد نظر ، گذاشتن پسورد و ذخیره آن در مسیر پروژه:



string s= System.AppDomain.CurrentDomain.BaseDirectory;

using (ZipFile zip =
new ZipFile())


{


zip.Password =

"12345678";

zip.UseUnicodeAsNecessary =

true;




//
zip.AddDirectory(@"D:\MyFolder");

zip.AddFile(@"D:\File1.txt");

zip.Save(s+
@"NameFile.zip");

}