WPF 多线程处理(5)
项目的目录:
以下是FileStroage的三个类:
分别是FileHelper,FileInfos,Win32

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace Automatically.FileStroage { public class FileHelper { public static FileInfos GetFileInfo(string path) { var fileInfos = new FileInfos(); FileInfo fi = new FileInfo(path); fileInfos.Icon = Win32.GetIcon(path, true); fileInfos.Name = fi.Name; fileInfos.Path = fi.FullName; fileInfos.Size = fi.Length; return fileInfos; } } }

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; namespace Automatically.FileStroage { public class FileInfos { public Icon Icon { get; set; } public string Name { get; set; } public string Path { get; set; } public long Size { get; set; } } }

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; using System.Drawing; namespace Automatically.FileStroage { public class Win32 { [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 Win32() { } 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); } } }
下一篇:WPF 多线程处理(6)
上一篇:WPF 多线程处理(4)
作者:风清扬 No.1
出处:http://www.cnblogs.com/fengqingyangNo1
如果,您认为阅读这篇博客让您有些收获,不妨点击一下右下角的【推荐】按钮。
如果,您希望更容易地发现我的新博客,不妨点击一下右下角的 【关注 风清扬 No.1】。
因为,我的写作热情也离不开您的肯定支持。
感谢您的阅读,如果您对我的博客所讲述的内容有兴趣,请继续关注我的后续博客.
出处:http://www.cnblogs.com/fengqingyangNo1
如果,您认为阅读这篇博客让您有些收获,不妨点击一下右下角的【推荐】按钮。
如果,您希望更容易地发现我的新博客,不妨点击一下右下角的 【关注 风清扬 No.1】。
因为,我的写作热情也离不开您的肯定支持。
感谢您的阅读,如果您对我的博客所讲述的内容有兴趣,请继续关注我的后续博客.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 单线程的Redis速度为什么快?
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 展开说说关于C#中ORM框架的用法!
· SQL Server 2025 AI相关能力初探
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库