Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
GeneralRe: overriding equals Pin
Gilbert Consellado1-Jul-15 19:41
professionalGilbert Consellado1-Jul-15 19:41 
GeneralRe: overriding equals Pin
F-ES Sitecore2-Jul-15 0:20
professionalF-ES Sitecore2-Jul-15 0:20 
SuggestionRe: overriding equals Pin
Richard Deeming2-Jul-15 2:06
mveRichard Deeming2-Jul-15 2:06 
GeneralRe: overriding equals Pin
Gilbert Consellado2-Jul-15 3:27
professionalGilbert Consellado2-Jul-15 3:27 
AnswerRe: overriding equals Pin
Brisingr Aerowing1-Jul-15 19:25
professionalBrisingr Aerowing1-Jul-15 19:25 
QuestionExecuting Powershell command from C# Pin
sudhi1641-Jul-15 4:15
sudhi1641-Jul-15 4:15 
AnswerRe: Executing Powershell command from C# Pin
phil.o1-Jul-15 5:57
professionalphil.o1-Jul-15 5:57 
QuestionDirectoryInfo.GetAccessControl() throws InvalidOperationException "Method failed with unexpected error code 1" Pin
Gerd Krause1-Jul-15 3:08
Gerd Krause1-Jul-15 3:08 
Hello, I am new in this forum and this time I need your friendly help:

my problem is, that this exception appears when "pathName" is an UNC path name.

C#
public Boolean CheckPathName(string pathName, 
                             FileSystemRights rights,
                             AccessControlType type)
{
    Boolean ok = false;
    try
    {
        _accountName = System.Environment.UserDomainName +
                       '\\' + System.Environment.UserName;
        if (Directory.Exists(pathName))
        {
            AddDirectorySecurity(pathName, _accountName, rights, type);
            ok = true;
        }
    }
    catch (InvalidOperationException ex)
    {
        throw ex;
    }            
    return ok;
}

// Adds an ACL entry on the specified directory for the specified account.
public static void AddDirectorySecurity(string FileName, string Account, FileSystemRights Rights, AccessControlType ControlType)
{
    // Create a new DirectoryInfo object.
    DirectoryInfo dInfo = new DirectoryInfo(FileName);
    // Get a DirectorySecurity object that represents the 
    // current security settings. // THROWS EXCEPTION
    DirectorySecurity dSecurity = dInfo.GetAccessControl();
    // Add the FileSystemAccessRule to the security settings. 
    dSecurity.AddAccessRule(new FileSystemAccessRule(Account, Rights, ControlType));
    // Set the new access settings.
    dInfo.SetAccessControl(dSecurity);
}


can someone help me?
SuggestionRe: DirectoryInfo.GetAccessControl() throws InvalidOperationException "Method failed with unexpected error code 1" Pin
Richard Deeming1-Jul-15 7:46
mveRichard Deeming1-Jul-15 7:46 
GeneralRe: DirectoryInfo.GetAccessControl() throws InvalidOperationException "Method failed with unexpected error code 1" Pin
Gerd Krause1-Jul-15 23:21
Gerd Krause1-Jul-15 23:21 
QuestionHow i can pause/resume a thread in window form application ? Pin
Husnul karim30-Jun-15 20:59
Husnul karim30-Jun-15 20:59 
AnswerRe: How i can pause/resume a thread in window form application ? Pin
Pete O'Hanlon30-Jun-15 23:36
mvePete O'Hanlon30-Jun-15 23:36 
QuestionHow to check if pieces are ordered Pin
Aleksandar Jeftic30-Jun-15 11:22
Aleksandar Jeftic30-Jun-15 11:22 
GeneralRe: How to check if pieces are ordered Pin
PIEBALDconsult30-Jun-15 11:25
mvePIEBALDconsult30-Jun-15 11:25 
GeneralRe: How to check if pieces are ordered Pin
Aleksandar Jeftic2-Jul-15 4:50
Aleksandar Jeftic2-Jul-15 4:50 
AnswerRe: How to check if pieces are ordered Pin
Freak3030-Jun-15 21:20
Freak3030-Jun-15 21:20 
QuestionHotSpot Management via ICS in C# Pin
spaika30-Jun-15 4:31
spaika30-Jun-15 4:31 
QuestionInsert Image in excel with transperancy enabled Pin
Member 1179983729-Jun-15 23:56
Member 1179983729-Jun-15 23:56 
AnswerRe: Insert Image in excel with transperancy enabled Pin
Richard Deeming30-Jun-15 1:02
mveRichard Deeming30-Jun-15 1:02 
QuestionRead/Write App Settings Not Working Pin
Kevin Marois29-Jun-15 9:16
professionalKevin Marois29-Jun-15 9:16 
AnswerRe: Read/Write App Settings Not Working Pin
Eddy Vluggen29-Jun-15 10:36
professionalEddy Vluggen29-Jun-15 10:36 
GeneralRe: Read/Write App Settings Not Working Pin
Kevin Marois29-Jun-15 11:23
professionalKevin Marois29-Jun-15 11:23 
QuestionRe: Read/Write App Settings Not Working Pin
Eddy Vluggen29-Jun-15 11:28
professionalEddy Vluggen29-Jun-15 11:28 
AnswerRe: Read/Write App Settings Not Working Pin
Kevin Marois29-Jun-15 12:00
professionalKevin Marois29-Jun-15 12:00 
GeneralRe: Read/Write App Settings Not Working Pin
Pete O'Hanlon29-Jun-15 19:42
mvePete O'Hanlon29-Jun-15 19:42 

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.