public List <fundcode> getFund() { string filePath = @"//192.168.96.7/Datawarehouse/"; DirectoryInfo dirInfo = new DirectoryInfo(filePath); DirectoryInfo rootdir = dirInfo.Root; List <fundcode> fund = new List <fundcode>(); DirectoryInfo[] dirInfos = rootdir.GetDirectories("*.*"); foreach (DirectoryInfo d in dirInfos) { if (d.Name.Length < 6) { DirectoryInfo[] subDir = d.GetDirectories("*.*"); foreach (DirectoryInfo sb in subDir) { if (sb.Name == "Wait" || sb.Name == "wait") { // Debug.WriteLine("---------------- " + sb.Name); fundcode fc = new fundcode(); fc.fundecode = d.Name; fund.Add(fc); } } } } return(fund); }
public IActionResult Index(string name) { ViewBag.title = "Datawarehouse"; string filePath = @"//192.168.96.7/Datawarehouse/"; Debug.WriteLine("Path : " + filePath); DirectoryInfo dirInfo = new DirectoryInfo(filePath); DirectoryInfo rootdir = dirInfo.Root; DirectoryInfo[] dirInfos = rootdir.GetDirectories("*.*"); Debug.WriteLine("***************** Directory **************"); foreach (DirectoryInfo d in dirInfos) { if (d.Name.Length < 6) { //Debug.WriteLine("Direc Name : " + d.Name); DirectoryInfo[] subDir = d.GetDirectories("*.*"); foreach (DirectoryInfo sb in subDir) { if (sb.Name == "Wait" || sb.Name == "wait") { // Debug.WriteLine("---------------- " + sb.Name); fundcode fc = new fundcode(); fc.fundecode = d.Name; fund.Add(fc); DirectoryInfo[] sub2 = sb.GetDirectories("*.*"); if (sub2.Length > 0) { GetDirInWait(sb, d.Name); } else { FileInfo[] getFileW = sb.GetFiles("*.*"); int i = 0; foreach (FileInfo files2 in getFileW) { FileDirModel map = new FileDirModel(); if (i == 0) { map.path = sb.FullName; map.fileName = files2.Name; map.fundcode = d.Name; } else { map.path = ""; map.fileName = files2.Name; map.fundcode = d.Name; } i++; ListFile.Add(map); //Debug.WriteLine("************************* " + files2.Name); } } } } } } file_name = name; ViewBag.file_name = file_name; ViewBag.fund = fund; ViewBag.listfile = ListFile; return(View()); }