Call the attrib command to view the folder attributes.

Source: Internet
Author: User

Private string getdirectoryattrib (string directoryname)
{
System. Diagnostics. PROCESS p = new system. Diagnostics. Process ();
String T1;
If (directory. exists (directoryname ))
{
P. startinfo. createnowindow = true;
P. startinfo. useshellexecute = false;
P. startinfo. redirectstandardoutput = true;
P. startinfo. filename = "attrib ";
P. startinfo. Arguments = directoryname;
P. Start ();
P. waitforexit ();
T1 = P. standardoutput. readtoend ();
T1 = t1.substring (0, t1.indexof (directoryname ));
T1 = t1.replace ("","");
}
Else
{
T1 = "";
}
Return T1;
}

The doscommand attrib is used to return the attributes of the folder,
The returned value contains s as the system attribute, H as the hidden attribute, and r as the read-only attribute.
The preceding Code has a small problem: If the folder name contains spaces, the attrib command cannot be identified,
Therefore, an error is reported.

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.