public ActionResult ListFile(string folderId) { var imgPath = ""; string filePath = ""; if (!string.Equals(folderId, "/", StringComparison.CurrentCultureIgnoreCase)) { var folder = new FOLDER() { ID = folderId, NAME = "Test folder" }; ViewBag.FolderName = folder.NAME; ViewBag.FolderId = folderId; var tmp = folderId.TrimStart('/'); imgPath = "/Uploads/images/" + tmp + "/"; filePath = Server.MapPath("~/Uploads/images/" + tmp + "/"); } else { ViewBag.SubUrl = "null"; ViewBag.FolderName = "Root"; imgPath = "/Uploads/images/"; filePath = Server.MapPath("~/Uploads/images/"); } var files = new List <FILE>(); //GetFileByFolderId(folderId); //var imgPath = "/Uploads/images/" + folderId + "/"; //string filePath = Server.MapPath("~/Uploads/images/" + folderId + "/"); try { DirectoryInfo d = new DirectoryInfo(filePath); foreach (var f in d.GetFiles()) { FILE file = new FILE(); file.NAME = f.Name; file.ID = f.Name; file.FOLDERID = folderId; file.FULLPATH = folderId + "/" + f.Name; //file.FULLPATH = folderId + f.Name; file.URL = imgPath + f.Name; files.Add(file); } } catch { } ViewBag.Files = files; return(View("ListFile")); }
public FolderViewModel(FOLDER item) { ID = item.ID; Folder = AsyncHelper.RunSync(async() => await item.GetFolderAsync()); if (Folder == null) { NotAvaliable = true; Disk = "N/A"; Path = item.Path; FolderName = Consts.Localizer.GetString("NotAvaliableText"); SongsCount = 0; return; } Disk = item.Path.Split(':').FirstOrDefault(); Path = item.Path; FolderName = Folder.DisplayName; SongsCount = item.SongsCount; }
// get an array of folder children from the passed folder or from root if folder == null public FOLDER[] GetFolders(FOLDER folder) { FOLDER[] folders; long curTOCOfs = 0; // index into TOC byte[] folderOfs = new byte[4]; folders = new FOLDER[folder.numFolders]; inStream.Seek(folder.folderTOCOfs, SeekOrigin.Begin); curTOCOfs = inStream.Position; for(int i = 0; i<folder.numFolders;i++) { inStream.Read(folderOfs, 0, 4); curTOCOfs = inStream.Position; folders[i] = GetFolderFromOfs(BitConverter.ToUInt32(folderOfs, 0)); inStream.Seek(curTOCOfs, SeekOrigin.Begin); } return (folders); }
//public FILE GetFile(String name); // get an array of file children from the passed folder public FILE[] GetFiles(FOLDER folder) { FILE[] files; long curTOCOfs = 0; // index into TOC byte[] fileOfs = new byte[4]; files = new FILE[folder.numFiles]; inStream.Seek(folder.fileTOCOfs, SeekOrigin.Begin); curTOCOfs = inStream.Position; for (int i = 0; i < folder.numFiles; i++) { inStream.Read(fileOfs, 0, 4); curTOCOfs = inStream.Position; files[i] = GetFileFromOfs(BitConverter.ToUInt32(fileOfs, 0)); inStream.Seek(curTOCOfs, SeekOrigin.Begin); } return (files); }
private List <FOLDER> GetListFolder(DirectoryInfo[] subdirs, string parentId) { var folders = new List <FOLDER>(); if (subdirs != null && subdirs.Any()) { foreach (var item in subdirs) { FOLDER a = new FOLDER(); a.NAME = item.Name; a.ID = item.Name; a.PARENTID = parentId; folders.Add(a); if (item.GetDirectories() != null && item.GetDirectories().Any()) { folders.AddRange(GetListFolder(item.GetDirectories(), item.Name)); } } } return(folders); }
public String GetName(FOLDER folder) { return (GetNameFromOfs(folder.filenameOfs)); }
private FOLDER UnMarshalFolder(byte[] arr) { FOLDER str = new FOLDER(); int size = Marshal.SizeOf(str); IntPtr ptr = Marshal.AllocHGlobal(size); Marshal.Copy(arr, 0, ptr, size); str = (FOLDER)Marshal.PtrToStructure(ptr, str.GetType()); Marshal.FreeHGlobal(ptr); return str; }
private byte[] MarshalFolder(FOLDER str) { int size = Marshal.SizeOf(str); byte[] arr = new byte[size]; IntPtr ptr = Marshal.AllocHGlobal(size); Marshal.StructureToPtr(str, ptr, true); Marshal.Copy(ptr, arr, 0, size); Marshal.FreeHGlobal(ptr); return arr; }
private FOLDER GetFolder() { FOLDER folder = new FOLDER(); byte[] marshalled; folder.thisOffset = inStream.Position; marshalled = MarshalFolder(folder); inStream.Read(marshalled, 0, 0x14); folder = UnMarshalFolder(marshalled); folder.fileName = GetNameFromOfs(folder.filenameOfs); return (folder); }