I have a VB6 program that encrypts a file - and also - I have a folder lock program that I want to lock the folder (CLSID) to My Computer, Recycle Bin etc.....

But when I encrypt the file and try to lock the folder I get an error:

"The process cannot access the file because it is being used by another process."

The code it errors on is:

Code:
d.MoveTo(d.Parent.FullName + "\\" + d.Name + status);
Which is apart of:

Code:
DirectoryInfo d = new DirectoryInfo(folderBrowserDialog1.SelectedPath);
                string selectedpath = d.Parent.FullName + d.Name;
                if (folderBrowserDialog1.SelectedPath.LastIndexOf(".{") == -1)
                {
                    if (checkBox1.Checked)
                        setpassword(folderBrowserDialog1.SelectedPath);
                    if (!d.Root.Equals(d.Parent.FullName))
                    d.MoveTo(d.Parent.FullName + "\\" + d.Name + status);
                    else d.MoveTo(d.Parent.FullName + d.Name + status);
                    textBox1.Text = folderBrowserDialog1.SelectedPath;
                    pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\lock.jpg");
                }
                else
                {
                    status = getstatus(status);
                    bool s=checkpassword();
                    if (s)
Which is apart of a snipplet I got off this site somewhere.

Is there a way to make the folder lockable when a file inside is being used by another process?

Thanks in advanced

daveofgv