Accessing Windows File Icons in ASP.NET

  • Thread starter Thread starter nick
  • Start date Start date
N

nick

I'm wondering if it's possible to access and use windows file icons in
a webpage using, for example, the shell method SHGetFileInfo. I'm
writing a small asp.net app to browse directories on a server and
would like the icons to display as a regular windows directory
browser. Is this even possible?

The following link provides a class to do it in a VB app, but it uses
System.Drawing to display the icon. For the puposes of a webpage, I
assume I need a reference to a jpg or gif.

http://www.vbaccelerator.com/home/N...etting_File_Icons_Using_The_Shell/article.asp

Thanks in advance for any suggestions.

Nick
 
nick said:
I'm wondering if it's possible to access and use windows file icons in
a webpage using, for example, the shell method SHGetFileInfo. I'm
writing a small asp.net app to browse directories on a server and
would like the icons to display as a regular windows directory
browser. Is this even possible?

The following link provides a class to do it in a VB app, but it uses
System.Drawing to display the icon. For the puposes of a webpage, I
assume I need a reference to a jpg or gif.

True.

Create a separate aspx-file for the image like this:

<%@ Page Language="VB" %>
<%@ import Namespace="System.Drawing" %>
<%@ import Namespace="System.Drawing.Imaging" %>
<%@ import Namespace="System.Drawing.Drawing2D" %>
<script runat="server">
Sub Page_Init( sender As Object, e As EventArgs)
Response.ContentType = "image/gif"
Dim objBitmap As Bitmap= new Bitmap(16,16)
Dim filename As String = Request.QueryString("filename")
... bring your icon into the bitmap here ...
' Save the image to a file
objBitmap.Save(Response.OutputStream, ImageFormat.Gif)
End Sub
</script>

Display the result in your page like this:
<img src="imagefile.aspx?filename=whatever">

The main problem (as I have found) is that the .NET framework
doesn't support transparent GIF's.
Which is exactly what you would need for icons.

I wrote a similar project as you did, and finally, I gave up and I just
used a single static GIF image for the folders, and I didn't bother
about other file icons.
 
Back
Top