Beispiel #1
0
        public FileObject(string filePath)
        {
            this.filePath = filePath;

            SHFILEINFO shinfo = new SHFILEINFO();
            IntPtr hImgSmall = Win32.SHGetFileInfo(filePath, 0, ref shinfo, 
                (uint)Marshal.SizeOf(shinfo), Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON);

            try
            {
                fileIcon = Bitmap.FromHicon(shinfo.hIcon);
            }
            catch
            {
                fileIcon = null;
            }
            finally
            {
                try 
                {
                    Win32.DestroyIcon(shinfo.hIcon);
                }
                catch {}
            }

            FileStream fileStream = File.OpenRead(filePath);
            BinaryReader br = new BinaryReader(fileStream);
            fileData = br.ReadBytes((int)fileStream.Length);
            br.Close();
        }
Beispiel #2
0
 public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi,
     uint cbSizeFileInfo, uint uFlags);