C# code to deny access to local hard disk drives

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2008
Posts: 10
Reputation: getkiran1 is an unknown quantity at this point 
Solved Threads: 0
getkiran1 getkiran1 is offline Offline
Newbie Poster

C# code to deny access to local hard disk drives

 
0
  #1
Aug 8th, 2009
Hi,

Im Kiran. Can any one help me with the C# code for denying access to the local drives?? when anyone try to access a drive ( thru cmd or double clicking the drive directly) it shud nt b allowed.. for that..
So hw can we do that programattically..???

Plz help me.......
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,200
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 571
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: C# code to deny access to local hard disk drives

 
0
  #2
Aug 8th, 2009
You can't. Whatever you are trying to do you are going about it the wrong way. This is more to do with security policies than programming.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,923
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 276
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: C# code to deny access to local hard disk drives

 
0
  #3
Aug 8th, 2009
I think the closest you can get to the thing you want is to use a FileSystemWatcher class. But that will only work when your program is active of course.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,200
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 571
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: C# code to deny access to local hard disk drives

 
0
  #4
Aug 8th, 2009
Good morning danny

You're working on the weekends too I see
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 10
Reputation: getkiran1 is an unknown quantity at this point 
Solved Threads: 0
getkiran1 getkiran1 is offline Offline
Newbie Poster

Re: C# code to deny access to local hard disk drives

 
0
  #5
Aug 8th, 2009
hi sknake....
dnt knw y u said a big NO.... sorry, we can do with the System.Management namespace... i did dat bt still some prblm is der.. i mean i can deny access to read,write,delete etc but i cannot change it back to the allowed state... Classes are there like
myDirectorySecurity.AddAccessRule(new FileSystemAccessRule(User, FileSystemRights.FullControl, AccessControlType.Allow)); but it is nt wrkng unfortunately.. dats y....

Its possible with System.Management namespace ... ok???

Thankzzzzzzz
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 10
Reputation: getkiran1 is an unknown quantity at this point 
Solved Threads: 0
getkiran1 getkiran1 is offline Offline
Newbie Poster

Re: C# code to deny access to local hard disk drives

 
0
  #6
Aug 8th, 2009
hi ddanbe..
First of all thanx 4 ur reply...
Well i had done dat partilly with System.Management namespace... bt still som prblms... dats y...
ok i will check d FiuleSystemWatcher and wll let u knw..
Thanku sir.....
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: C# code to deny access to local hard disk drives

 
0
  #7
Aug 13th, 2009
sknake is right... This isn't a programming problem. This is more something that should be resolved by local security policies on a client machine. Are these machines part of a domain?
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 323
Reputation: Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough 
Solved Threads: 39
Diamonddrake's Avatar
Diamonddrake Diamonddrake is offline Offline
Posting Whiz

Re: C# code to deny access to local hard disk drives

 
0
  #8
Aug 13th, 2009
file systems manage drives access, not programs or operating systems. you can modify the filing system's access rights to users by using applications to modify the security permissions in the filing system, but It wasn't designed to be modified frequently like that. you could end up with a completely inaccessible drive.

There are much better ways to go about it. I agree with Scott and Dan. not only can you not. If you do find a way, you most certainly shouldn't.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC