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.