/// <summary> /// 获取文件 /// </summary> /// <param name="dir"></param> /// <returns></returns> private List <TreeNodeEntity> GetDirNode(string dir) { List <TreeNodeEntity> filesEntities = new List <TreeNodeEntity>(); string[] dirs = Directory.GetDirectories(dir); foreach (string InDir in dirs) { TreeNodeEntity dirNode = new TreeNodeEntity(); dirNode.Name = InDir.Substring(InDir.LastIndexOf("\\") + 1, InDir.Length - InDir.LastIndexOf("\\") - 1); dirNode.Open = false; dirNode.Children = GetDirNode(InDir); filesEntities.Add(dirNode); } string[] files = Directory.GetFiles(dir); foreach (string InFile in files) { TreeNodeEntity fileNode = new TreeNodeEntity(); CodeEntity ce = CodeOperation.GetCodeFromPath(dir.Replace( Server.MapPath(AppConfiger.GetProjectsDir(Server)), "") + "\\" + InFile.Substring(InFile.LastIndexOf("\\") + 1, InFile.Length - InFile.LastIndexOf("\\") - 1)); if (ce != null) { fileNode.Id = ce.Id; fileNode.Name = ce.Path.Substring(ce.Path.LastIndexOf("\\") + 1, ce.Path.Length - ce.Path.LastIndexOf("\\") - 1); fileNode.TargetName = "sourceFrame"; fileNode.UrlFormat = "/Viewer.aspx?id={0}"; filesEntities.Add(fileNode); } else { fileNode.Name = InFile.Substring(InFile.LastIndexOf("\\") + 1, InFile.Length - InFile.LastIndexOf("\\") - 1); filesEntities.Add(fileNode); } } return(filesEntities); }