How to get Information about Files, Folders, and subfolders and show them on a ASP.NET C# website , showing a folder image for folders and subfolders and a generic file image for all files contained in that folder and a link to open/download the file ?
Something like a file tree, that you click on the folder and it expands.
If this is an ASP Web Forms application you can bind the file result to a
TreeView. If this is an MVC app you can do a search from Tree View MVC for html helpers.
That's simply an link with an href if the files are within the application directory. Otherwise you'll need to write a bit of code related to the ASP framework you are using to stream the file back to the client. There are many examples of how to do this
on the web.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
248 Points
438 Posts
Get Information About Files, Folders and its subfolders and show on a website
Apr 19, 2017 05:11 PM|xandeq|LINK
How to get Information about Files, Folders, and subfolders and show them on a ASP.NET C# website , showing a folder image for folders and subfolders and a generic file image for all files contained in that folder and a link to open/download the file ?
Something like a file tree, that you click on the folder and it expands.
Thanks in advance!
All-Star
37131 Points
14993 Posts
Re: Get Information About Files, Folders and its subfolders and show on a website
Apr 19, 2017 05:26 PM|mgebhard|LINK
Learn how to use the System.IO namespace.
https://msdn.microsoft.com/en-us/library/07wt70x2(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/bb513869.aspx
You'll need to find icons. Font awesome has file images and it is free.
http://fontawesome.io/icons/
If this is an ASP Web Forms application you can bind the file result to a TreeView. If this is an MVC app you can do a search from Tree View MVC for html helpers.
https://demos.devexpress.com/MVCxNavigationAndLayoutDemos/TreeView/Callbacks
That's simply an link with an href if the files are within the application directory. Otherwise you'll need to write a bit of code related to the ASP framework you are using to stream the file back to the client. There are many examples of how to do this on the web.
Star
8650 Points
2882 Posts
Re: Get Information About Files, Folders and its subfolders and show on a website
Apr 20, 2017 09:32 AM|Cathy Zou|LINK
Hi xandeq,
For your problem, I make an simple. You could refer to it:
CodeBehind:
Output screenshot as below:
For more information please refer to the following link:
https://www.aspsnippets.com/Articles/Display-Directory-Folder-structure-using-ASPNet-TreeView-control-in-C-and-VBNet.aspx
Best regards
Cathy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.