-3

I recently saw this tutorial (please see before proceding). I tried it and it works fine. I want to write a program that will accomplish the same result, using a GUI. see image-

enter image description here

Specifically, i want the c# equivalent of:

Copy \B SrcImage + SrcArchive Result

where SrcImage, SrcArchive and Result are strings pointing to three files.

Does anyone know what I can do?

UPDATE #1: I tried this:

        //Writing a batch file containing the desired code in batch file 
        //language, and running it from a c# form.
        string BackSlashB = "-b";
        string lines = "@echo off \r copy "+ BackSlashB +" " + SrcJpg + " + " + SrcRar + " " + Destfile +  " \r pause";
        MessageBox.Show(lines);
        System.IO.StreamWriter batchfile = new System.IO.StreamWriter("c:\\temp.bat");
        batchfile.WriteLine(lines);
        batchfile.Close();
        System.Diagnostics.Process.Start("c:\\temp.bat");

A console window opens up and then disappears before i can read it's contents... Any ideas?

  • sorry about that, fixed it. here it is http://computer-pranks.wonderhowto.com/how-to/hide-your-secret-files-jpg-image-without-exposing-anything-ads-alternate-data-streams-0135035/ – Daren Lobo Feb 07 '15 at 09:08
  • Have you tried anything so far? – Asad Saeeduddin Feb 07 '15 at 09:12
  • not really... i've considered making the program create a new batch file and execute it externally, but that would be messy – Daren Lobo Feb 07 '15 at 09:15
  • you can do that, by passing these arguments in a Process. Since you haven't tried anything yet, I think, you must try this yourself. – Rohit Prakash Feb 07 '15 at 09:16
  • @DarenLobo, This might help you more [process.start() arguments](http://stackoverflow.com/questions/3268022/process-start-arguments) – Rohit Prakash Feb 07 '15 at 09:21

1 Answers1

0

Alright, I finally got it to work.

The problem was with the \r escape. for some odd reason, it has to be \r\n, or else the batch file will contain the code in one line. Also, I had to add apostrophes around each file name. Finally, i removed the pause and debug box, replacing them with a "check if file exists" in order to give the user a message that the task was completed.

Entire Code:

string lines = "@echo off" + "\r\n copy /b " + "\"" + SrcJpg + "\"" + " + " + "\"" + SrcRar + "\"" + " " + "\"" + Destfile + "\"";
        //MessageBox.Show(lines);
        System.IO.StreamWriter batchfile = new System.IO.StreamWriter("c:\\temp.bat");
        batchfile.WriteLine(lines);
        batchfile.Close();
        System.Diagnostics.Process.Start("c:\\temp.bat");

        if (File.Exists(Destfile))
        {
            MessageBox.Show("File Created!");
        }