C #. Net change folder Permissions

Source: Internet
Author: User

 

Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Using system. diagnostics;
/// <Summary>
/// Command Summary
/// </Summary>
Namespace command
{
Public class command
{
// <Summary>
// Run the specified command line
/// </Summary>
// <Param name = "cmd"> command </param>
// <Param name = "Arg"> command line parameters </param>
// <Param name = "comfirm"> write the confirmation information of the command line. </param>
// <Returns> </returns>
Public static string execute (string cmd, string Arg, string comfirm)
{
PROCESS p = new process ();
P. startinfo. filename = cmd;
P. startinfo. Arguments = ARG;
P. startinfo. useshellexecute = false;
P. startinfo. redirectstandardinput = true;
P. startinfo. redirectstandardoutput = true;
P. startinfo. redirectstandarderror = true;
P. startinfo. createnowindow = true;

P. Start ();
If (comfirm! = NULL)
P. standardinput. writeline (comfirm );
String MSG = P. standardoutput. readtoend ();
P. waitforexit ();
P. Close ();

Return MSG;
}
}
}

Call method command. Command. Execute ("cacls", filename + "/T/g everyone: F", "Y ");

Note that the cacls file name cannot contain spaces.

Method: you only need to use "" to cause the path.

For example, string filename = '"' + pathstr + '"';

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.