. Net get all the files that know the file quota and the quota except the specified file quota
Source: Internet
Author: User
/** // <Summary>
/// Obtain all the sub-files in the object category
/// </Summary>
String files = "";
Public string GetFiles (string dir)
{
DirectoryInfo dif = new DirectoryInfo (dir );
Int n = dif. GetFiles ("*. txt"). Length;
If (n> = 1)
{
Foreach (FileInfo fi in dif. GetFiles ("*. txt "))
{
Files + = fi. FullName. Trim () + "/";
}
}
Foreach (string di in Directory. GetDirectories (dir) // subfile catalog
{
GetFiles (di );
}
Return files;
}
/** // <Summary>
/// Except all the sub-files of the specified destination
/// </Summary>
/// <Param name = "dir"> </param>
Public void DeleteFiles (string dir)
{
DirectoryInfo dif = new DirectoryInfo (dir );
Int n = dif. GetFiles ("*"). Length;
If (n> = 1)
{
Foreach (FileInfo fi in dif. GetFiles ("*"))
{
File. Delete (fi. FullName );
}
}
Foreach (string di in Directory. GetDirectories (dir) // subfile catalog
{
DeleteFiles (di );
}
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.