如何在C#上跳过扫描系统卷信息文件夹

时间:2016-12-21 03:15:45

标签: c# getfiles

帮助,如何使用C#跳过磁盘D上的文件夹系统卷信息并扫描另一个文件夹.. 这是示例代码

public void scDirectory(string location, string password)
{
    var validExtensions = new[]
    {
        ".ogg", ".mp3", ".txt"
    };

    string[] files = Directory.GetFiles(location, "*", SearchOption.AllDirectories);

    string[] chDir = Directory.GetDirectories(location, "*", SearchOption.AllDirectories);
    for (int i = 0; i < files.Length; i++){
        string extension = Path.GetExtension(files[i]);
        if (validExtensions.Contains(extension))
        {
            scFile(files[i],password);
        }
    }

    for (int i = 0; i < chdDir.Length; i++){
        scDirectory(chDir[i],password);
    }
}

0 个答案:

没有答案