By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,760 Members | 1,630 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,760 IT Pros & Developers. It's quick & easy.

EFS: File.Encrypt Exception when a folder is in use

P: n/a
Hello

I'm using the File.Encrypt method (.net 2.0) to encrypt files and
folders (mark for encryption) on a local disk (XP SP2, 3DES, .net 2.0).
Unfortunatelly I get an exception when trying to mark the %desktop%
folder for encryption: "The process cannot access the file because it
is being used by another process).
Is there any possibility I can close handles that use the folder?

Thanks a lot in advance

Tom

Here's what I'm trying to do (snipped from msdn to keep focus on the
actual issue)
http://msdn2.microsoft.com/en-us/lib...e.encrypt.aspx

using System;
using System.IO;
using System.Security.AccessControl;

namespace FileSystemExample
{
class FileExample
{
public static void Main()
{
try
{
string FileName = @"C:\Documents and
Settings\USER1\Desktop";
AddEncryption(FileName);
}
catch (Exception e)
{ Console.WriteLine(e); }
}

public static void AddEncryption(string FileName)
{
File.Encrypt(FileName);
}
}
}

Aug 24 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
The desktop folder of the current logged on user is owned by the
explorer.exe process, you can't close file handles you don't own.
What stops you from encrypting each file in %desktop% individually?

Willy.
"tomtown.net" <to*******@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
| Hello
|
| I'm using the File.Encrypt method (.net 2.0) to encrypt files and
| folders (mark for encryption) on a local disk (XP SP2, 3DES, .net 2.0).
| Unfortunatelly I get an exception when trying to mark the %desktop%
| folder for encryption: "The process cannot access the file because it
| is being used by another process).
| Is there any possibility I can close handles that use the folder?
|
| Thanks a lot in advance
|
| Tom
|
| Here's what I'm trying to do (snipped from msdn to keep focus on the
| actual issue)
| http://msdn2.microsoft.com/en-us/lib...e.encrypt.aspx
|
| using System;
| using System.IO;
| using System.Security.AccessControl;
|
| namespace FileSystemExample
| {
| class FileExample
| {
| public static void Main()
| {
| try
| {
| string FileName = @"C:\Documents and
| Settings\USER1\Desktop";
| AddEncryption(FileName);
| }
| catch (Exception e)
| { Console.WriteLine(e); }
| }
|
| public static void AddEncryption(string FileName)
| {
| File.Encrypt(FileName);
| }
| }
| }
|
Aug 24 '06 #2

P: n/a
Hello Willy

Thanks for your post. The problem by doing so is, that every new file a
user creeates on the desktop won't be encrypted. :(
Maybe I can try executing the program a little earlier in the login
process :S

Thanks again

Tom

Aug 27 '06 #3

P: n/a

"tomtown.net" <to*******@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
| Hello Willy
|
| Thanks for your post. The problem by doing so is, that every new file a
| user creeates on the desktop won't be encrypted. :(
| Maybe I can try executing the program a little earlier in the login
| process :S
|
| Thanks again
|
| Tom
|

That's right, question is why do users create user files on the desktop in
the first place?. Anyway, you have to encrypt the folder before Explorer
starts.

Willy.


Aug 27 '06 #4

P: n/a
Hello Willy / everyone

I am now launching th eprogram using the
HKLM\SW\MS\\WNT\Winlogon\userinit Registry key, it works fine. I would
have prefered laucnhing it using the RunOnce, but the key permissions
have been restricted in my company. I can surely impersonate to write
the key, but it seems a user who has not full permissions on that key
will not be able to launch it's contents on startup.

Thanks for the inspiration

Tom

Aug 30 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.