2015-02-07 48 views
-3

我最近看到了this tutorial(請在前面看看)。我試過了,它工作正常。 我想寫一個程序,使用GUI來完成相同的結果。看到圖像 -如何將jpg文件附加到rar文件?

enter image description here

具體來說,我想C#的等效:

Copy \B SrcImage + SrcArchive Result 

其中SrcImageSrcArchiveResult是指向三個文件的字符串。

有誰知道我能做什麼?

更新#1: 我嘗試這樣做:

 //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"); 

一個控制檯窗口打開,然後消失之前,我可以看它的內容... 任何想法?

+0

比較遺憾的是,固定它。這裏是http://computer-pranks.wonderhowto.com/how-to/hide-your-secret-files-jpg-image-without-exposing-anything-ads-alternate-data-streams-0135035/ – 2015-02-07 09:08:42

+0

你有沒有到目前爲止嘗試過什麼 – 2015-02-07 09:12:50

+0

不是真的......我考慮過讓程序創建一個新的批處理文件並在外部執行它,但是通過將這些參數傳遞給一個Process,您可以做到這一點很麻煩 – 2015-02-07 09:15:17

回答

0

好的,我終於明白了。

問題出在\ r轉義。出於某種奇怪的原因,它必須是\ r \ n,否則批處理文件將在一行中包含代碼。 另外,我必須在每個文件名稱周圍添加撇號。 最後,我刪除了暫停和調試框,將它們替換爲「檢查是否存在文件」,以便爲用戶提供任務已完成的消息。

整個代碼:

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!"); 
     }