473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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
4 6340
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
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

"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: chris | last post by:
I'm writing a small app to help me learn more about cryptography. All it does is encrypt all of the files in directory A, and put the encrypted versions of the files in directory B. It then...
4
by: G. Richard Bellamy | last post by:
I'm trying to unset the Encrypted attribute on all the files in a path. The attribute is not getting set. What am I doing wrong? Perhaps there's another newsgroup I can send this to? Here's...
0
by: williams | last post by:
I am trying to encrypt data in a SQLServer 2000 Cluster using Microsoft EFS. I have successfully encrypted a standalone DB but we are having difficulty with the Cluster. I am only encrypting the...
13
by: Leo | last post by:
Hi I had asekd previously a question qith regards to running a DLL file from ASP. It was not running for me. Bo error returned, nothing, Just an empty string (when it should have not been...
2
MMcCarthy
by: MMcCarthy | last post by:
I am looking at encrypting a folder on my computer with EFS (on XP Pro). I have never used this before and was looking for some advice. I found a very good article on the subject ...
2
by: trahul87 | last post by:
Windows EFS allows users to encrypt files which thus can be accessed only by authorized users. To allow users on other systems to access the files the certificate must be exported. But if the same...
2
by: Unzy | last post by:
Hi all, I know this probably has been asked a thousand times, and that you need the right certificates and key to decrypt efs encrypted files, but here is my problem anyway, i thank all for those...
0
by: lildiapaz | last post by:
Hi, everyone I'm developing a c# windows application that allows the user to encrypt any file type. i would like to encrypt the file using a powerful encrypting algorithm. I've tried to use the...
0
by: Silke Anita Mühlemann | last post by:
Hi there, I'm trying to encrypt Files with EFS, by using functions of the advapi32 dll. But I have problems with the function 'AddUsersToEncryptFile'. I have the name of the file which I want...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.