The process cannot access the file because it is being used by another process #2
<p>I'm making a little backup tool... And I've got a little problem, no idea how to fix this. So that why I'm asking here... CODE:</p>

<pre><code>strDirectoryData = dlg1.SelectedPath;
strCheckBoxData = "true";
clsCrypto aes = new clsCrypto();
aes.IV = "MyIV";     // your IV
aes.KEY = "MyKey";    // your KEY      
strDirectoryEncryptedData = aes.Encrypt(strDirectoryData, CipherMode.CBC);
strCheckBoxEncryptedData = aes.Encrypt(strCheckBoxData, CipherMode.CBC);

StreamWriter dirBackup = new StreamWriter(dirBackupPath, false, Encoding.UTF8);
StreamWriter checkBackup = new StreamWriter(autoBackupPath, false, Encoding.UTF8);
dirBackup.WriteLine(strDirectoryEncryptedData, Encoding.UTF8);
dirBackup.Close();
checkBackup.WriteLine(strCheckBoxData, Encoding.UTF8);
checkBackup.Close();'
</code></pre>

<p>Getting a error every time - The process cannot access the file because it is being used by another process...</p>

<p>Also i have this in Form1_Load</p>

<pre><code>if (!Directory.Exists(folderPath))
{
    Directory.CreateDirectory(folderPath);
    string strCheckBoxData;
    string strDirectoryData;
    string strCheckBoxEncryptedData;
    string strDirectoryEncryptedData;
    strDirectoryData = "Nothing here";
    strCheckBoxData = "false";
    clsCrypto aes = new clsCrypto();
    aes.IV = "MyIV";     // your IV
    aes.KEY = "MyKey";    // your KEY      
    strDirectoryEncryptedData = aes.Encrypt(strDirectoryData, CipherMode.CBC);
    strCheckBoxEncryptedData = aes.Encrypt(strCheckBoxData, CipherMode.CBC);

    StreamWriter dirBackup = new StreamWriter(dirBackupPath, false, Encoding.UTF8);
    StreamWriter checkBackup = new StreamWriter(autoBackupPath, false, Encoding.UTF8);
    dirBackup.WriteLine(strDirectoryEncryptedData);
    dirBackup.Close();
    checkBackup.WriteLine(strCheckBoxEncryptedData);
    checkBackup.Close();
}
else
{
    string strCheckBoxDecryptedData;
    string strDirectoryDecryptedData;

    StreamReader dirEncrypted = new StreamReader(dirBackupPath);
    StreamReader checkEncrypted = new StreamReader(autoBackupPath);
</code></pre>

<p>Any ideas?</p>
