المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : how to i delete the file



C# Programming
12-10-2009, 02:27 AM
Dear friends ...

i encrypted and decrypt file with CryptoStream.

if some one modified the data in the encrypted file.(edit the data with notepad)

now i decrypt the file (it is not possible... i understad that) chunk by chunk. at the last while closing the file (CryptoStream.close())

i get an error .. now i could not delete the file becase it is Used by another porcess ... and i could not close the file for deleting, because closing stream throws error.


FileStream fStreame = new FileStream(sDestinationFile, FileMode.Create);

CryptoStream cStream = new CryptoStream(fStreame, alg.CreateDecryptor(), CryptoStreamMode.Write);

try
{

int readBytes = rStream.Read(bValues, 0, nBuffersize);
cStream.Write(bValues, 0, readBytes);

}
catch(Ex)
{
}
finally
{
rStream.Close();
cStream.Close();
}

please suggest me something...

by

Joe