Saturday, April 11, 2009

Merge Files (Steganography)

Note : This is simple merge file techniques. You need Advance Level coding for Converting it to steganography.

Introduction:I have used FileStream class for merging two files. First file will be opened for appending. Second file will be opened and read into a byte array. Then this byte array is written onto the first file stream and then both file steams will be closed. Now you have successfully appended the first file with the second file.Uses:If are left with two parts of video or audio file you have no option to play it because the player may not be able to read partial files. This is useful for joining files of same format splitted due to some size restrictions.
private void cmdMerge_Click(object sender, EventArgs e)
{
string sFile1 = txtFile1.Text;
string sFile2 = txtFile2.Text;
FileStream fs1=null;
FileStream fs2=null;
try
{
fs1 = File.Open(sFile1, FileMode.Append);
fs2 = File.Open(sFile2, FileMode.Open);
byte[] fs2Content = new byte[fs2.Length];
fs2.Read(fs2Content, 0, (int)fs2.Length);
fs1.Write(fs2Content, 0, (int)fs2.Length);
MessageBox.Show("Done!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + " : " + ex.StackTrace);
}
finally
{
fs1.Close();
fs2.Close();
}
}
This is simple file merging , You can convert it to your need

No comments:

Post a Comment