找到了这样一段代码:
using System;
using System.Runtime.InteropServices;
using System.Drawing;
namespace WindowsAppTmp
{
public class ExtractIcon
{
[DllImport("Shell32.dll")]
private static extern int SHGetFileInfo
(
string pszPath,
uint dwFileAttributes,
out SHFILEINFO psfi,
uint cbfileInfo,
SHGFI uFlags
); [StructLayout(LayoutKind.Sequential)]
private struct SHFILEINFO
{
public SHFILEINFO(bool b)
{
hIcon = IntPtr.Zero; iIcon = 0; dwAttributes = 0; szDisplayName = ""; szTypeName = "";
}
public IntPtr hIcon;
public int iIcon;
public uint dwAttributes;
[MarshalAs(UnmanagedType.LPStr, SizeConst = 260)]
public string szDisplayName;
[MarshalAs(UnmanagedType.LPStr, SizeConst = 80)]
public string szTypeName;
}; private ExtractIcon()
{
} private enum SHGFI
{
SmallIcon = 0x00000001,
LargeIcon = 0x00000000,
Icon = 0x00000100,
DisplayName = 0x00000200,
Typename = 0x00000400,
SysIconIndex = 0x00004000,
UseFileAttributes = 0x00000010
}
public static Icon GetIcon(string strPath, bool bSmall)
{
SHFILEINFO info = new SHFILEINFO(true);
int cbFileInfo = Marshal.SizeOf(info);
SHGFI flags;
if (bSmall)
flags = SHGFI.Icon | SHGFI.SmallIcon | SHGFI.UseFileAttributes;
else
flags = SHGFI.Icon | SHGFI.LargeIcon | SHGFI.UseFileAttributes; SHGetFileInfo(strPath, 256, out info, (uint)cbFileInfo, flags);
return Icon.FromHandle(info.hIcon);
}
}
}请问怎么在网页里把这个文件的图标显示出来?
我是这样写的
ExtractIcon.GetIcon("D:\\wwwroot\\web.gif", true);
但是什么也没有显示,请教该怎么做?
using System;
using System.Runtime.InteropServices;
using System.Drawing;
namespace WindowsAppTmp
{
public class ExtractIcon
{
[DllImport("Shell32.dll")]
private static extern int SHGetFileInfo
(
string pszPath,
uint dwFileAttributes,
out SHFILEINFO psfi,
uint cbfileInfo,
SHGFI uFlags
); [StructLayout(LayoutKind.Sequential)]
private struct SHFILEINFO
{
public SHFILEINFO(bool b)
{
hIcon = IntPtr.Zero; iIcon = 0; dwAttributes = 0; szDisplayName = ""; szTypeName = "";
}
public IntPtr hIcon;
public int iIcon;
public uint dwAttributes;
[MarshalAs(UnmanagedType.LPStr, SizeConst = 260)]
public string szDisplayName;
[MarshalAs(UnmanagedType.LPStr, SizeConst = 80)]
public string szTypeName;
}; private ExtractIcon()
{
} private enum SHGFI
{
SmallIcon = 0x00000001,
LargeIcon = 0x00000000,
Icon = 0x00000100,
DisplayName = 0x00000200,
Typename = 0x00000400,
SysIconIndex = 0x00004000,
UseFileAttributes = 0x00000010
}
public static Icon GetIcon(string strPath, bool bSmall)
{
SHFILEINFO info = new SHFILEINFO(true);
int cbFileInfo = Marshal.SizeOf(info);
SHGFI flags;
if (bSmall)
flags = SHGFI.Icon | SHGFI.SmallIcon | SHGFI.UseFileAttributes;
else
flags = SHGFI.Icon | SHGFI.LargeIcon | SHGFI.UseFileAttributes; SHGetFileInfo(strPath, 256, out info, (uint)cbFileInfo, flags);
return Icon.FromHandle(info.hIcon);
}
}
}请问怎么在网页里把这个文件的图标显示出来?
我是这样写的
ExtractIcon.GetIcon("D:\\wwwroot\\web.gif", true);
但是什么也没有显示,请教该怎么做?
解决方案 »
- 根据条件判断,弹出对话框 (确认,取消)
- 谁知道这个正则表达式怎么写???
- 如何动态的刷新树?
- 怎么把字符串分离出来
- table中的单元格如何才能保持原有数据的换行格式,支持自动换行呢?
- 动态创建gridview的问题
- datagrid两列,一列值根据另一行值变化而变化?
- 不小心安装了英语版的.NET Framework,如何安装成中文版的?
- 如何设置iframe中的heml控件属性。document.all.ifm.document.all.DropDownList1....设置无效。
- 为什么表格中只显示字段名,不显示数据?在线等!
- 求含checkbox的treeview树型结构的简单例子(200分求)
- 请教MIME的概念。
imgtest为一个图片按扭
你的是设置样式表,跟我这个没关系啊