Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tomtown.net - 24 Aug 2006 09:11 GMT
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/library/system.io.file.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);
       }
   }
}
Willy Denoyette [MVP] - 24 Aug 2006 17:36 GMT
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.

| Hello
|
[quoted text clipped - 39 lines]
|    }
| }
tomtown.net - 27 Aug 2006 11:45 GMT
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
Willy Denoyette [MVP] - 27 Aug 2006 13:29 GMT
| Hello Willy
|
[quoted text clipped - 6 lines]
|
| 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.
tomtown.net - 30 Aug 2006 08:15 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.