46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.IO;
|
|
|
|
namespace BLL
|
|
{
|
|
public static class ExtractFilePath
|
|
{
|
|
private static int GetCharCount(String str)
|
|
{
|
|
string[] strNum = str.Split('\\');
|
|
|
|
return strNum.Length;
|
|
}
|
|
private static string FileList(String listPath, String listName)
|
|
{
|
|
string path = string.Empty;
|
|
//In order to improve the search speed, check the depth;
|
|
if (GetCharCount(listPath) > 6)
|
|
{
|
|
return path;
|
|
}
|
|
|
|
DirectoryInfo dir = new DirectoryInfo(listPath);
|
|
foreach (DirectoryInfo subdir in dir.GetDirectories())
|
|
{
|
|
if (subdir.ToString().ToLower().Contains(listName.ToLower()))
|
|
{
|
|
path = listPath + "\\" + subdir;
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
FileList(listPath + "\\" + subdir, listName);
|
|
}
|
|
}
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
}
|
|
}
|