PKCS7 encryptor & decryptor in C#
<p>I have been working on encryptor &amp;&amp; decryptor in C#.I have two buttons for two different operations.I want to decrypt that encrypted file.But,I getting the following the error.</p>

<pre><code>PKCS7 padding is invalid and cant be removed 
</code></pre>

<p>Code:</p>

<pre><code> private void button1_Click(object sender, System.EventArgs e)

 {try {

 if (DialogResult.OK==openFileDialog1.ShowDialog(this))

 {FileStream dosya=new FileStream("deneme.xxx",FileMode.Create);

  RijndaelManaged uygula=new RijndaelManaged();

 CryptoStream yenidosya=new CryptoStream(dosya,uygula.CreateEncryptor(),CryptoStreamMode.Write);

  FileStream tamam=new FileStream(openFileDialog1.FileName,FileMode.Open);

 int uzunluk;

 while((uzunluk=tamam.ReadByte())!=-1)

 {yenidosya.WriteByte((byte)uzunluk);}

 MessageBox.Show("islem tamam");

 tamam.Close();

 yenidosya.Close();

 dosya.Close();

 }

 }

 catch(Exception caught)

 {MessageBox.Show(caught.Message);}

 }

  private void button2_Click(object sender, System.EventArgs e)

 {

 try

 {

 if (DialogResult.OK==openFileDialog2.ShowDialog(this))

 {FileStream dosya=new FileStream(openFileDialog2.FileName,FileMode.Open);

 RijndaelManaged uygula=new RijndaelManaged();

 CryptoStream yenidosya=new CryptoStream(dosya,uygula.CreateDecryptor(),CryptoStreamMode.Read);

 FileStream tamam=new FileStream("denemeeeee.txt",FileMode.Create);

 int uzunluk;

 while((uzunluk=yenidosya.ReadByte())!=-1)

 {tamam.WriteByte((byte)uzunluk);}

 tamam.Close();

 yenidosya.Close();

 dosya.Close();

 MessageBox.Show("islem tamam");

  }

 }

 catch(Exception caught)

 {MessageBox.Show(caught.Message);}

 }

 }
</code></pre>
