ItsMods

Full Version: change single file lzma maker to multiple in c#
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
guys i use this code to create my files for App updater.
with this code i can just select one files every time and also the output copied to clipboard and zipped files crated in same directory near unzipped files.
BUT:
i need to edit this code for:

1)possible to select multiple files (all files with files in folders and sub folders) or i think its better give a folder address to add all files also the files in sub folders.
2)put output data on a file named "info.xml" except clipboard in somewhere.(each data for each files in per line)
an example for output data on clipboard is:
CSHARP Code
  1. <ContentFile Name="logo.bmp" Size="109976" SHA1Hash="280EFF2ADD6557E90C542263B1C7971F8EBF19A8" CompressedSize="8625" />

3) at last put zipped files (lzma format) on the other place with same files names and folders and sub folders with included files.

Guys i need full code.
Thank you for Help

this is my code:

CSHARP Code
  1. namespace UpdateBuilder
  2. {
  3. public partial class MainFrm : Form
  4. {
  5.  
  6. public string fileName = "";
  7. public string output = "";
  8.  
  9. public MainFrm()
  10. {
  11. InitializeComponent();
  12. }
  13.  
  14. private void browseBtn_Click(object sender, EventArgs e)
  15. {
  16. // Show a file browsing dialog
  17. OpenFileDialog dialog = new OpenFileDialog();
  18. dialog.Filter = "All files (*.*)|*.*";
  19. dialog.InitialDirectory = Directory.GetCurrentDirectory();
  20. dialog.Title = "Select a file to build";
  21. if (dialog.ShowDialog() == DialogResult.OK)
  22. {
  23. // Place the selected file's path in the input textbox
  24. inBox.Text = dialog.FileName;
  25. fileName = dialog.SafeFileName;
  26. }
  27. }
  28.  
  29. private void buildBtn_Click(object sender, EventArgs e)
  30. {
  31. if (inBox.Text != "")
  32. {
  33. // Disable all controls
  34. inBox.Enabled = false;
  35. browseBtn.Enabled = false;
  36. buildBtn.Enabled = false;
  37.  
  38. // Start the converion utility
  39. ProcessStartInfo startInfo = new ProcessStartInfo();
  40. startInfo.FileName = "lzma.exe";
  41. startInfo.Arguments = "e " + inBox.Text + " " + inBox.Text + ".lzma -d21";
  42. startInfo.CreateNoWindow = true;
  43. startInfo.WindowStyle = ProcessWindowStyle.Hidden;
  44.  
  45. using (Process p = Process.Start(startInfo))
  46. {
  47. // And wait for it to finish
  48. while (!p.HasExited)
  49. {
  50. Thread.Sleep(100);
  51. }
  52. }
  53.  
  54. // Generate that final string
  55. FileInfo inFile = new FileInfo(inBox.Text);
  56. FileInfo outFile = new FileInfo(inBox.Text + ".lzma");
  57. output = "<ContentFile Name=\"" + fileName + "\" Size=\"" + inFile.Length.ToString() + "\" SHA1Hash=\"" + HashCalc.GetSHA1Hash(inBox.Text) + "\" CompressedSize=\"" + outFile.Length.ToString() + "\" />";
  58.  
  59. // Re-enable the controls
  60. inBox.Enabled = true;
  61. browseBtn.Enabled = true;
  62. buildBtn.Enabled = true;
  63.  
  64. // Show notice and copy output to clipboard
  65. Clipboard.SetText(output);
  66. MessageBox.Show("Build succeeded.\nCopied output to clipboard.");
  67. }
  68. else
  69. {
  70. MessageBox.Show("Please select a file to build.");
  71. }
  72. }
  73.  
  74. }
  75. }
pleas some one help me