using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.IO;
|
using System.Linq;
|
using System.Text;
|
|
namespace WIDESEA_Services.Services.Log
|
{
|
public class LogService
|
{
|
|
public ArrayList al = new ArrayList();
|
//我把ArrayList当成动态数组用,非常好用
|
public ArrayList GetAllDirList(string strBaseDir)
|
{
|
DirectoryInfo di = new DirectoryInfo(strBaseDir);
|
DirectoryInfo[] diA = di.GetDirectories();
|
for (int i = 0; i < diA.Length; i++)
|
|
{
|
al.Add(diA[i].FullName);
|
GetAllDirList(diA[i].FullName);
|
}
|
|
return al;
|
}
|
|
|
|
//获得指定路径下所有文件名
|
public static List<FileNames> getFileName(List<FileNames> list, string filepath)
|
{
|
DirectoryInfo root = new DirectoryInfo(filepath);
|
foreach (FileInfo f in root.GetFiles())
|
{
|
list.Add(new FileNames
|
{
|
label = f.FullName, //f.Name,
|
path = f.FullName,
|
});
|
}
|
return list;
|
}
|
//获得指定路径下的所有子目录名
|
// <param name="list">文件列表</param>
|
// <param name="path">文件夹路径</param>
|
public static List<FileNames> GetallDirectory(List<FileNames> list, string path)
|
{
|
DirectoryInfo root = new DirectoryInfo(path);
|
var dirs = root.GetDirectories();
|
if (dirs.Count() != 0)
|
{
|
foreach (DirectoryInfo d in dirs)
|
{
|
list.Add(new FileNames
|
{
|
label = d.Name,
|
path = d.FullName,
|
children = GetallDirectory(new List<FileNames>(), d.FullName)
|
}); ;
|
}
|
}
|
list = getFileName(list, path);
|
return list;
|
}
|
|
}
|
|
|
public class FileNames
|
{
|
//public int id { get; set; }
|
//public string text { get; set; }
|
//public state state { get; set; }
|
//public List<FileNames> children { get; set; }
|
//public string icon { get; set; }
|
|
public string label { get; set; }
|
public List<FileNames> children { get; set; }
|
public string path { get; set; }
|
}
|
public class state
|
{
|
public bool opened { get; set; }
|
}
|
}
|