Click here to Skip to main content
15,888,968 members
Home / Discussions / C#
   

C#

 
QuestionChecking folder read write access C# Pin
raesa10-Nov-08 17:58
raesa10-Nov-08 17:58 
AnswerRe: Checking folder read write access C# Pin
Brij10-Nov-08 18:52
mentorBrij10-Nov-08 18:52 
QuestionChecking folder read write access C# Pin
raesa10-Nov-08 17:58
raesa10-Nov-08 17:58 
AnswerRe: Checking folder read write access C# Pin
N a v a n e e t h10-Nov-08 19:59
N a v a n e e t h10-Nov-08 19:59 
GeneralRe: Checking folder read write access C# Pin
raesa10-Nov-08 20:15
raesa10-Nov-08 20:15 
GeneralRe: Checking folder read write access C# Pin
Tri Q Tran20-Jul-09 21:15
Tri Q Tran20-Jul-09 21:15 
GeneralRe: Checking folder read write access C# Pin
Kelvin Armstrong18-Oct-09 7:00
Kelvin Armstrong18-Oct-09 7:00 
AnswerRe: Checking folder read write access C# Pin
User-Rock25-Nov-09 19:13
User-Rock25-Nov-09 19:13 
Hi,
You can try following code block to check if the directory is having Write Access.
It checks the FileSystemAccessRule.


string directoryPath = "C:\\XYZ"; //folderBrowserDialog.SelectedPath;<br />
               bool isWriteAccess = false;<br />
               try<br />
               {<br />
                  AuthorizationRuleCollection collection = Directory.GetAccessControl(directoryPath).GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));<br />
                  foreach (FileSystemAccessRule rule in collection)<br />
                  {<br />
                     if (rule.AccessControlType == AccessControlType.Allow)<br />
                     {<br />
                        isWriteAccess = true;<br />
                        break;<br />
                     }<br />
                  }<br />
               }<br />
               catch (UnauthorizedAccessException ex)<br />
               {<br />
                  isWriteAccess = false;<br />
               }<br />
               catch (Exception ex)<br />
               {<br />
                  isWriteAccess = false;<br />
               }<br />
               if (!isWriteAccess)<br />
               {<br />
                 //handle notifications                 <br />
               }

GeneralRe: Checking folder read write access C# Pin
Liu Junfeng15-Mar-11 0:19
Liu Junfeng15-Mar-11 0:19 
QuestionDiscovering location of csc.exe through code Pin
krafix10-Nov-08 13:24
krafix10-Nov-08 13:24 
AnswerRe: Discovering location of csc.exe through code Pin
netJP12L10-Nov-08 14:40
netJP12L10-Nov-08 14:40 
AnswerRe: Discovering location of csc.exe through code Pin
Ravi Bhavnani10-Nov-08 16:41
professionalRavi Bhavnani10-Nov-08 16:41 
GeneralRe: Discovering location of csc.exe through code Pin
Alan Balkany11-Nov-08 3:36
Alan Balkany11-Nov-08 3:36 
QuestionHow do I find a XML element based on attribute Pin
Ola E10-Nov-08 11:02
Ola E10-Nov-08 11:02 
AnswerRe: How do I find a XML element based on attribute Pin
Pete O'Hanlon10-Nov-08 11:07
mvePete O'Hanlon10-Nov-08 11:07 
GeneralRe: How do I find a XML element based on attribute Pin
Ola E10-Nov-08 19:03
Ola E10-Nov-08 19:03 
GeneralRe: How do I find a XML element based on attribute Pin
Tuwing.Sabado10-Nov-08 21:13
Tuwing.Sabado10-Nov-08 21:13 
QuestionProblem Pin
netJP12L10-Nov-08 9:57
netJP12L10-Nov-08 9:57 
AnswerRe: Problem Pin
Pedram Behroozi10-Nov-08 10:13
Pedram Behroozi10-Nov-08 10:13 
GeneralRe: Problem Pin
netJP12L10-Nov-08 10:22
netJP12L10-Nov-08 10:22 
QuestionCAB Single Instance App Pin
Brian Jenkins10-Nov-08 9:48
Brian Jenkins10-Nov-08 9:48 
QuestionWindows Forms vs DirectX Pin
Generico30010-Nov-08 7:38
Generico30010-Nov-08 7:38 
AnswerRe: Windows Forms vs DirectX Pin
Wendelius10-Nov-08 7:46
mentorWendelius10-Nov-08 7:46 
AnswerRe: Windows Forms vs DirectX Pin
Mark Salsbery10-Nov-08 8:25
Mark Salsbery10-Nov-08 8:25 
GeneralRe: Windows Forms vs DirectX Pin
Mark Churchill10-Nov-08 15:59
Mark Churchill10-Nov-08 15:59 

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.