public static bool ZipFile(string path) { try { //ten file zip string strZipFilename = ""; //password string strPass = ""; //duong dan file xml can zip string[] filenames = System.IO.Directory.GetFiles(path, "*.xml"); clsCryptography genPass = new clsCryptography(); foreach (string file in filenames) { //lay file nam xml , thay extension thang .zip strZipFilename = file.Substring(0, file.Length - 4) + ".zip"; //generate password strPass = genPass.GenPWDByFilename(strZipFilename); //zip file clsZip.ZipFiles(file, strZipFilename, strPass); //xoa file xml sau khi da zip xong System.IO.File.Delete(file); } return(true); } catch { return(false); } }
public static void SaveZipFile2(DataSet ds, String filename) { ds.WriteXml(filename, XmlWriteMode.WriteSchema); FileInfo file = new FileInfo(filename); String nameWithoutExt = GetNameWithoutExt(file.Name); String newName = file.DirectoryName + "/" + nameWithoutExt + ".zip"; clsCryptography crypto = new clsCryptography(); String pwd = crypto.GenPWDByFilename(newName); clsZip.ZipFiles(filename, newName, pwd); file.Delete(); }
public static DataSet ReadZipFile(String filename) { FileInfo file = new FileInfo(filename); String tmpFolder = GenerateTempFolderName(file.FullName); Directory.CreateDirectory(tmpFolder); clsCryptography crypto = new clsCryptography(); String pwd = crypto.GenPWDByFilename(file.Name); clsZip.UnzipFile(file.FullName, tmpFolder, pwd); String filename2 = GetFirstFile(tmpFolder); DataSet ds = new DataSet(); ds.ReadXml(filename2); DeleteFolder(tmpFolder); return ds; }
public static DataSet ReadZipFile(String filename) { FileInfo file = new FileInfo(filename); String tmpFolder = GenerateTempFolderName(file.FullName); Directory.CreateDirectory(tmpFolder); clsCryptography crypto = new clsCryptography(); String pwd = crypto.GenPWDByFilename(file.Name); clsZip.UnzipFile(file.FullName, tmpFolder, pwd); String filename2 = GetFirstFile(tmpFolder); DataSet ds = new DataSet(); ds.ReadXml(filename2); DeleteFolder(tmpFolder); return(ds); }
public static bool ZipFile(string path) { try { //ten file zip string strZipFilename = ""; //password string strPass = ""; //duong dan file xml can zip string[] filenames = System.IO.Directory.GetFiles(path, "*.xml"); clsCryptography genPass = new clsCryptography(); foreach (string file in filenames) { //lay file nam xml , thay extension thang .zip strZipFilename = file.Substring(0, file.Length -4) + ".zip"; //generate password strPass = genPass.GenPWDByFilename(strZipFilename); //zip file clsZip.ZipFiles(file, strZipFilename, strPass); //xoa file xml sau khi da zip xong System.IO.File.Delete(file); } return true; } catch { return false; } }
/// <summary> /// Zip file /// </summary> /// <remarks> /// Author : Nguyen Bao Nguyen G3 /// Created day : 24-Apr-2011 /// </remarks> public void ZipFileParam(string strParamPath) { try { //string strFileNameToEncode = ""; string strZipFilename = ""; string strPass = ""; string strPath = strParamPath; string[] filenames = Directory.GetFiles(strPath, "*.xml"); clsCryptography genPass = new clsCryptography(); foreach (string file in filenames) { strZipFilename = file.Substring(0, file.Length -4)+".zip"; //strFileNameToEncode = file.Substring(0, file.Length -4); strPass = genPass.GenPWDByFilename(strZipFilename); clsZip.ZipFiles(file, strZipFilename, strPass); File.Delete(file); } } catch (Exception ex) { throw ex; } }
public static void SaveZipFile(DataSet ds, String filename) { FileInfo file = new FileInfo(filename); String nameWithoutExt = GetNameWithoutExt(file.Name); String newName = file.DirectoryName + "/" + nameWithoutExt + ".xml"; ds.WriteXml(newName, XmlWriteMode.WriteSchema); clsCryptography crypto = new clsCryptography(); String pwd = crypto.GenPWDByFilename(filename); clsZip.ZipFiles(newName, filename, pwd); File.Delete(newName); }