Click here to Skip to main content
15,907,395 members
Home / Discussions / C#
   

C#

 
AnswerRe: 2D Array Trim Pin
PIEBALDconsult6-Oct-09 4:54
mvePIEBALDconsult6-Oct-09 4:54 
Questionhide header and footer while printing a webpage in C# [modified] Pin
vasavi.p5-Oct-09 23:56
vasavi.p5-Oct-09 23:56 
GeneralRe: hide header and footer while printing a webpage in C# Pin
Rajesh Anuhya6-Oct-09 1:22
professionalRajesh Anuhya6-Oct-09 1:22 
GeneralRe: hide header and footer while printing a webpage in C# Pin
vasavi.p6-Oct-09 1:50
vasavi.p6-Oct-09 1:50 
GeneralRe: hide header and footer while printing a webpage in C# Pin
Eddy Vluggen6-Oct-09 8:35
professionalEddy Vluggen6-Oct-09 8:35 
Questionimport C char** to C# in a struct Pin
MCALLAN5-Oct-09 22:29
MCALLAN5-Oct-09 22:29 
AnswerRe: import C char** to C# in a struct Pin
Richard MacCutchan5-Oct-09 23:50
mveRichard MacCutchan5-Oct-09 23:50 
AnswerRe: import C char** to C# in a struct Pin
Pete O'Hanlon5-Oct-09 23:52
mvePete O'Hanlon5-Oct-09 23:52 
AnswerRe: import C char** to C# in a struct Pin
Daniel Grunwald6-Oct-09 2:47
Daniel Grunwald6-Oct-09 2:47 
AnswerRe: import C char** to C# in a struct Pin
Luc Pattyn6-Oct-09 4:57
sitebuilderLuc Pattyn6-Oct-09 4:57 
GeneralRe: import C char** to C# in a struct Pin
Richard MacCutchan6-Oct-09 6:05
mveRichard MacCutchan6-Oct-09 6:05 
GeneralRe: import C char** to C# in a struct Pin
Dan Neely6-Oct-09 7:14
Dan Neely6-Oct-09 7:14 
QuestionRight Click Menu Pin
AhmedMasum5-Oct-09 22:09
AhmedMasum5-Oct-09 22:09 
AnswerRe: Right Click Menu Pin
OriginalGriff5-Oct-09 22:40
mveOriginalGriff5-Oct-09 22:40 
GeneralRe: Right Click Menu Pin
AhmedMasum5-Oct-09 23:01
AhmedMasum5-Oct-09 23:01 
GeneralRe: Right Click Menu Pin
Mycroft Holmes5-Oct-09 23:15
professionalMycroft Holmes5-Oct-09 23:15 
GeneralRe: Right Click Menu Pin
Muammar©5-Oct-09 23:34
Muammar©5-Oct-09 23:34 
GeneralRe: Right Click Menu Pin
AhmedMasum6-Oct-09 17:44
AhmedMasum6-Oct-09 17:44 
GeneralRe: Right Click Menu Pin
Muammar©6-Oct-09 21:01
Muammar©6-Oct-09 21:01 
QuestionAbout listbox use in DatagridView in window application Pin
sanjay307845-Oct-09 21:34
sanjay307845-Oct-09 21:34 
AnswerRe: About listbox use in DatagridView in window application Pin
Richard MacCutchan5-Oct-09 23:58
mveRichard MacCutchan5-Oct-09 23:58 
QuestionHow to give Write permission for a Folder? Pin
MikeSharp5-Oct-09 19:29
MikeSharp5-Oct-09 19:29 
Hi,

How to enable write permission for a folder , I googled internet for some sample programs, I got few programs but these were on the basis on Domain name and User name! I would like to know how this can be achieved on a standalone system ? Do we require Domain name and User Name for changing permission of a folder?

I have attached a small program of with this issue, kindly review it, it is executing but there is write permission is not enabled with this.

using System;
using System.IO;
using System.Security.AccessControl;
using System.Windows.Forms;

namespace FileSystemExample
{
    class FileExample
    {
        public static void Main()
        {
            string DomainName = System.Environment.UserDomainName.ToString();
            DomainName += @"\";
            string AccountName = System.Environment.UserName.ToString();
            DomainName += AccountName;
                 

            try
            {
                string folderName = @"C:\Inetpub\ftproot";

                Console.WriteLine("Adding access control entry for "
                    + folderName);

                // Add the access control entry to the file.
                AddFileSecurity(folderName,DomainName,FileSystemRights.WriteExtendedAttributes, AccessControlType.Allow);

                Console.WriteLine("Removing access control entry from "
                    + folderName);

                // Remove the access control entry from the file.

                  RemoveFileSecurity(folderName, DomainName,FileSystemRights.WriteExtendedAttributes, AccessControlType.Allow);

                Console.WriteLine("Done.");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }

        // Adds an ACL entry on the specified file for the specified account.
        public static void AddFileSecurity(string folderName, string account,
            FileSystemRights rights, AccessControlType controlType)
        {


            // Get a FileSecurity object that represents the
            // current security settings.
            FileSecurity fSecurity = File.GetAccessControl(folderName);

            // Add the FileSystemAccessRule to the security settings.
            fSecurity.AddAccessRule(new FileSystemAccessRule(account,
                rights, controlType));

            // Set the new access settings.
            File.SetAccessControl(folderName, fSecurity);

        }

        // Removes an ACL entry on the specified file for the specified account.
        public static void RemoveFileSecurity(string folderName, string account,
            FileSystemRights rights, AccessControlType controlType)
        {

            // Get a FileSecurity object that represents the
            // current security settings.
            FileSecurity fSecurity = File.GetAccessControl(folderName);

            // Remove the FileSystemAccessRule from the security settings.
            fSecurity.RemoveAccessRule(new FileSystemAccessRule(account,
                rights, controlType));

            // Set the new access settings.
            File.SetAccessControl(folderName, fSecurity);

        }
    }
}


Mike
AnswerRe: How to give Write permission for a Folder? Pin
Calla5-Oct-09 21:59
Calla5-Oct-09 21:59 
GeneralRe: How to give Write permission for a Folder? Pin
MikeSharp5-Oct-09 23:43
MikeSharp5-Oct-09 23:43 
GeneralRe: How to give Write permission for a Folder? Pin
stancrm6-Oct-09 1:19
stancrm6-Oct-09 1:19 

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.