Indianblues 0 Newbie Poster

Hi,

Actyally I am trying to merge two text files. I found the code for that on the net for c#. It worked for me.

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();
            }
            
        }
//openfiledialog
        private void cmdBrowseFile1_Click(object sender, EventArgs e)
        {
            ofdFile1.ShowDialog();
            txtFile1.Text = ofdFile1.FileName;
        }
//openfiledialog

        private void cmdBrowseFile2_Click(object sender, EventArgs e)
        {
            ofdFile2.ShowDialog();
            txtFile2.Text = ofdFile2.FileName;
        }

Now I want to implement the above code in ASP.NET using c#. So I have taken fileupload control and in the code I changed like this ,but its working.(no compilation errors but files are merging)
 
private void cmdMerge_Click(object sender, EventArgs e)
        {
            string sFile1 = fileupload1.FileName;
            string sFile2 = fileupload2.FileName;
            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);
                label.text = "Done!”;
            }
            catch (Exception ex)
            {
                            }
            finally
            {
                fs1.Close();
                fs2.Close();
            }
            
        }

Whats wrong with the above code. Pls look into my code and provide me the solution.

Thanks