private void btn_file_pack_Click(object sender, RoutedEventArgs e) { setLog("\nOpen File.."); using (System.Windows.Forms.OpenFileDialog openFileDialog1 = new System.Windows.Forms.OpenFileDialog()) { openFileDialog1.Filter = "Binary Files|*.bin"; openFileDialog1.Title = "Select a Target File"; if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { SelectedFilePath = openFileDialog1.FileName; setLog(string.Format("\nSelected File Path : {0}", SelectedFilePath)); YamEncrpty.Yam yam = new YamEncrpty.Yam("ABCDEFGHIJKLMNOPQR"); setLog("\nFile Packing..."); byte[] data = yam.Encode(YamEncrpty.PackUtility.readFile(SelectedFilePath)); string uname = SelectedFilePath.Replace(".bin", ".bz"); using (FileStream fs = new FileStream(uname, FileMode.Create)) { fs.Write(data, 0, data.Length); } setLog("\nFile Packing Complete..Check it"); } } }
private void btn_folder_pack_Click(object sender, RoutedEventArgs e) { setLog("\nOpen Folder.."); using (System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog()) { System.Windows.Forms.DialogResult result = folderDialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { SelectedFolderPath = folderDialog.SelectedPath; setLog(string.Format("\nSelected Folder Path : {0}", SelectedFolderPath)); YamEncrpty.Yam yam = new YamEncrpty.Yam("ABCDEFGHIJKLMNOPQR"); DirectoryInfo dir = new DirectoryInfo(SelectedFolderPath); FileInfo[] dirFiles = dir.GetFiles("*.bin"); setLog("\nFolder Files Packing..."); foreach (FileInfo file in dirFiles) { string filePath = file.FullName; setLog(string.Format("\nPacking.. : {0}", filePath)); byte[] data = yam.Encode(YamEncrpty.PackUtility.readFile(filePath)); string uname = SelectedFilePath.Replace(".bin", ".bz"); using (FileStream fs = new FileStream(uname, FileMode.Create)) { fs.Write(data, 0, data.Length); } } setLog("\nFile Packing Complete..Check it"); } } }