Click here to Skip to main content
15,903,175 members
Home / Discussions / C#
   

C#

 
QuestionHow to Create Virtual Drive? Pin
Pawan Kiran2-Mar-10 18:17
Pawan Kiran2-Mar-10 18:17 
AnswerRe: How to Create Virtual Drive? Pin
Saksida Bojan2-Mar-10 18:42
Saksida Bojan2-Mar-10 18:42 
GeneralRe: How to Create Virtual Drive? Pin
Pawan Kiran2-Mar-10 18:57
Pawan Kiran2-Mar-10 18:57 
GeneralRe: How to Create Virtual Drive? Pin
Saksida Bojan2-Mar-10 19:00
Saksida Bojan2-Mar-10 19:00 
QuestionMessage Removed Pin
2-Mar-10 9:09
Kennebel2-Mar-10 9:09 
AnswerRe: WPF Nested Grid Sizing Pin
AspDotNetDev2-Mar-10 17:12
protectorAspDotNetDev2-Mar-10 17:12 
GeneralRe: WPF Nested Grid Sizing Pin
Kennebel3-Mar-10 3:13
Kennebel3-Mar-10 3:13 
QuestionNot sure why second Access Rule is required for User account write access Pin
CTaylor892-Mar-10 8:31
CTaylor892-Mar-10 8:31 
While logged in as an administrator in Windows 7,I create a directory(RS)in the ProgramData directory and a text file. I then write a string to the file. When I log in as a User account, I am able to write to the created file as long as I add the second Access Rule for the user. It does not make any sense to me why I have to add this second rule. I have tried applying the same permissions from the second User rule to the first User rule, and it still will not allow the User account to write to the file. Why do I have to add this second rule? Also why is it that FileSystemRights.FullControl is not really what it claims to be? After all if I gave someone full control of my car they would assume they could do anything with it, wouldn't they?

StringBuilder sbPath = new StringBuilder(40);
sbPath.Append(Environment.GetEnvironmentVariable("ALLUSERSPROFILE"));
sbPath.Append(@"\RS");

// Create a DirectorySecurity object
DirectoryInfo dInfo = new DirectoryInfo(sbPath.ToString());

if (!dInfo.Exists)
{
// Add ACL entrys to Directory before it is created
DirectorySecurity dSecurity = new DirectorySecurity();

dSecurity.AddAccessRule(new FileSystemAccessRule(new NTAccount("Administrators"),
FileSystemRights.FullControl | FileSystemRights.Write, InheritanceFlags.None,
PropagationFlags.None, AccessControlType.Allow));

dSecurity.AddAccessRule(new FileSystemAccessRule(new NTAccount("Users"),
FileSystemRights.FullControl | FileSystemRights.Modify | FileSystemRights.Synchronize,
InheritanceFlags.None,
PropagationFlags.InheritOnly, AccessControlType.Allow));

// *** Need this rule added in order for a user login to get access. Why?
dSecurity.AddAccessRule(new FileSystemAccessRule(new NTAccount("Users"),
FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.InheritOnly, AccessControlType.Allow));

dInfo.Create(dSecurity);

sbPath.Append(@"\thefile.txt");

// Create directory under C:\ProgramData
FileStream fs = File.Create(sbPath.ToString());
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine("Some Data");
sw.Close();
fs.Close();
Craig

AnswerRe: Not sure why second Access Rule is required for User account write access Pin
DaveyM692-Mar-10 10:22
professionalDaveyM692-Mar-10 10:22 
GeneralRe: Not sure why second Access Rule is required for User account write access Pin
CTaylor892-Mar-10 12:12
CTaylor892-Mar-10 12:12 
AnswerRe: Not sure why second Access Rule is required for User account write access Pin
CTaylor892-Mar-10 13:34
CTaylor892-Mar-10 13:34 
GeneralRe: Not sure why second Access Rule is required for User account write access Pin
DaveyM692-Mar-10 13:56
professionalDaveyM692-Mar-10 13:56 
QuestionWindows Service, FileSystemWatcher + Polling [modified] Pin
krazykoder2-Mar-10 6:23
krazykoder2-Mar-10 6:23 
AnswerRe: Windows Service, FileSystemWatcher + Polling Pin
Paulo Zemek2-Mar-10 6:36
Paulo Zemek2-Mar-10 6:36 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
PIEBALDconsult2-Mar-10 8:50
mvePIEBALDconsult2-Mar-10 8:50 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
Paulo Zemek2-Mar-10 9:48
Paulo Zemek2-Mar-10 9:48 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
krazykoder2-Mar-10 10:55
krazykoder2-Mar-10 10:55 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
PIEBALDconsult2-Mar-10 12:38
mvePIEBALDconsult2-Mar-10 12:38 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
krazykoder2-Mar-10 9:23
krazykoder2-Mar-10 9:23 
GeneralRe: Windows Service, FileSystemWatcher + Polling [modified] Pin
Paulo Zemek2-Mar-10 9:39
Paulo Zemek2-Mar-10 9:39 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
krazykoder3-Mar-10 9:32
krazykoder3-Mar-10 9:32 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
Paulo Zemek3-Mar-10 13:33
Paulo Zemek3-Mar-10 13:33 
GeneralRe: Windows Service, FileSystemWatcher + Polling [modified] Pin
krazykoder4-Mar-10 6:26
krazykoder4-Mar-10 6:26 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
krazykoder4-Mar-10 8:41
krazykoder4-Mar-10 8:41 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
Paulo Zemek4-Mar-10 16:05
Paulo Zemek4-Mar-10 16:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.