Reputation: 8350
I need to show the ICONS corresponding to file type. For example i do have "sample.doc" in a string, which i show it in a anchor tag as link to make it downloadable. The link will have file name as shown below
<a title="Sample" target="_blank" href="\files\sample.doc">Sample</a>
What i need is i want the link to be shown like below
There are many filetypes i would require to show on the web page. How can I achieve this. A starting point will be good for me to continue with it.
Upvotes: 0
Views: 2801
Reputation: 21
We can show file according to file extension in asp.net. All we need to download file icon images then write some code to check extension of file and get file icon according to that.
Following function can be used to get file Icon:
private string GetIconForFile(string FileName)
{
string extension = Path.GetExtension(FileName);
extension = extension.Trim('.').ToLower();
return "~/fileicons/" + extension + ".png";
}
Here is the link to full example:http://programmerskills.blogspot.in/2016/05/show-file-icons-with-filename-in-aspnet.html
Upvotes: 0
Reputation: 19820
You can do everything on client side. There are helping links:
Upvotes: 0
Reputation: 3883
I usually do this (pseudo-code)
foreach(var file in files){
var extension = Path.GetExtension(file)
...
<a title="Sample" target="_blank" href="\files\sample.doc">
<img src="/images/@(extension).png" />
Sample
</a>
}
Upvotes: 1