Click here to Skip to main content
15,892,697 members
Home / Discussions / C#
   

C#

 
AnswerRe: To modify table column. Pin
Md. Marufuzzaman11-Oct-09 23:37
professionalMd. Marufuzzaman11-Oct-09 23:37 
GeneralRe: To modify table column. Pin
Md. Marufuzzaman11-Oct-09 23:41
professionalMd. Marufuzzaman11-Oct-09 23:41 
QuestionTimeout expired Pin
MozhdehQeraati11-Oct-09 19:12
MozhdehQeraati11-Oct-09 19:12 
AnswerRe: Timeout expired Pin
Saksida Bojan11-Oct-09 23:03
Saksida Bojan11-Oct-09 23:03 
AnswerRe: Timeout expired Pin
Md. Marufuzzaman11-Oct-09 23:48
professionalMd. Marufuzzaman11-Oct-09 23:48 
AnswerRe: Timeout expired Pin
Luc Pattyn12-Oct-09 0:15
sitebuilderLuc Pattyn12-Oct-09 0:15 
AnswerRe: Timeout expired Pin
Dave Kreskowiak12-Oct-09 8:25
mveDave Kreskowiak12-Oct-09 8:25 
QuestionChanging Folder Permission using C# Pin
MikeSharp11-Oct-09 18:21
MikeSharp11-Oct-09 18:21 
Hi All,

I want to change a folder permission, by default the folder has "Read" permission , I want to change it to both "Read" & "Write" permission. I tried to use sample programs in MSDN , but some how it is not working, I have attached my source code with this message, If there is any useful pointers to this problems kindly let me know, u r help will be much appriciated

using System;
using System.IO;
using System.Security.AccessControl;

namespace FileSystemExample
{
    class DirectoryExample
    {
        public static void Main()
        {
            try
            {
                string DirectoryName = @"C:\Inetpub\ftproot";

                Console.WriteLine("Adding access control entry for " + DirectoryName);
                // Add the access control entry to the directory.
                AddDirectorySecurity(DirectoryName, @"MYDOMAIN\MyAccount", FileSystemRights.Write, AccessControlType.Allow);
                Console.WriteLine("Removing access control entry from " + DirectoryName);
                // Remove the access control entry from the directory.
                RemoveDirectorySecurity(DirectoryName, @"MYDOMAIN\MyAccount", FileSystemRights.Write, AccessControlType.Allow);
                Console.WriteLine("Done.");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.ReadLine();
        }

        // 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.
            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);

        }

        // Removes an ACL entry on the specified directory for the specified account.
        public static void RemoveDirectorySecurity(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.
            DirectorySecurity dSecurity = dInfo.GetAccessControl();

            // Add the FileSystemAccessRule to the security settings. 
            dSecurity.RemoveAccessRule(new FileSystemAccessRule(Account,
            Rights,
            ControlType));

            // Set the new access settings.
            dInfo.SetAccessControl(dSecurity);

        }
    }
}


Mike
QuestionList of classes as a property of a class Pin
Protus11-Oct-09 16:06
Protus11-Oct-09 16:06 
AnswerRe: List of classes as a property of a class Pin
N a v a n e e t h11-Oct-09 17:00
N a v a n e e t h11-Oct-09 17:00 
QuestionStreamReader -> StreamWriter... file comes out much bigger !! Pin
je198011-Oct-09 8:56
je198011-Oct-09 8:56 
AnswerRe: StreamReader -> StreamWriter... file comes out much bigger !! Pin
harold aptroot11-Oct-09 8:59
harold aptroot11-Oct-09 8:59 
AnswerRe: StreamReader -> StreamWriter... file comes out much bigger !! [modified] Pin
Jaime Olivares11-Oct-09 18:47
Jaime Olivares11-Oct-09 18:47 
GeneralRe: StreamReader -> StreamWriter... file comes out much bigger !! Pin
riced12-Oct-09 6:13
riced12-Oct-09 6:13 
GeneralRe: StreamReader -> StreamWriter... file comes out much bigger !! Pin
Jaime Olivares12-Oct-09 6:40
Jaime Olivares12-Oct-09 6:40 
GeneralRe: StreamReader -> StreamWriter... file comes out much bigger !! Pin
riced12-Oct-09 6:56
riced12-Oct-09 6:56 
GeneralRe: StreamReader -> StreamWriter... file comes out much bigger !! Pin
Jaime Olivares12-Oct-09 7:39
Jaime Olivares12-Oct-09 7:39 
Questionextract files with the filestream Pin
nhqlbaislwfiikqraqnm11-Oct-09 8:15
nhqlbaislwfiikqraqnm11-Oct-09 8:15 
AnswerRe: extract files with the filestream Pin
Christian Graus11-Oct-09 10:27
protectorChristian Graus11-Oct-09 10:27 
Questiondll loading? Pin
nhqlbaislwfiikqraqnm1-Apr-21 23:29
nhqlbaislwfiikqraqnm1-Apr-21 23:29 
AnswerRe: dll loading? Pin
Richard MacCutchan11-Oct-09 8:45
mveRichard MacCutchan11-Oct-09 8:45 
GeneralRe: dll loading? Pin
Not Active11-Oct-09 8:53
mentorNot Active11-Oct-09 8:53 
GeneralRe: dll loading? Pin
Richard MacCutchan11-Oct-09 9:29
mveRichard MacCutchan11-Oct-09 9:29 
AnswerRe: dll loading? Pin
Not Active11-Oct-09 8:48
mentorNot Active11-Oct-09 8:48 
AnswerRe: dll loading? Pin
Nissim Salomon11-Oct-09 9:36
Nissim Salomon11-Oct-09 9:36 

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.