1、获取指定文件夹的全路径
适用于不知道文件夹的准确名称,使用关键词获取文件夹的全称,并返回全路径
private string GetFolderName(string path,string key)
{
DirectoryInfo theFolder = new DirectoryInfo(path);
//遍历文件夹
foreach (DirectoryInfo NextFolder in theFolder.GetDirectories())
{
if (NextFolder.Name.ToUpper().IndexOf(key.ToUpper()) >= 0)
{
return NextFolder.Name;
}
}
return " ";
}
2、获取指定文件夹下所有的pdf文件全路径
private List<string> GetAllPDFFiles()
{
List<string> fileNames = new List<string>();
string mainPath = @"Y:\Tech-center\test\"