Changeset 293


Ignore:
Timestamp:
3/25/2008 12:39:31 PM (6 years ago)
Author:
lowjoel
Message:

When calling File.GetFileDescription? or File.GetFileIcon?, the path provided must end with a trailing \ if the path is a directory or volume.

Location:
branches/eraser6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/Eraser/TaskDataSelectionForm.cs

    r283 r293  
    4545                    DriveItem item = new DriveItem(); 
    4646                    item.Drive = drive.Substring(0, drive.Length - 1); 
    47                     item.Label = Eraser.Util.File.GetFileDescription(item.Drive); 
    48                     item.Icon = Eraser.Util.File.GetFileIcon(item.Drive); 
     47                    item.Label = Eraser.Util.File.GetFileDescription(item.Drive + 
     48                        Path.DirectorySeparatorChar); 
     49                    item.Icon = Eraser.Util.File.GetFileIcon(item.Drive + 
     50                        Path.DirectorySeparatorChar); 
    4951                    unusedDisk.Items.Add(item); 
    5052                } 
  • branches/eraser6/Util/File.cs

    r292 r293  
    7878        /// </summary> 
    7979        /// <param name="path">A string that contains the path and file name for 
    80         /// the file in question. Both absolute and relative paths are valid.</param> 
     80        /// the file in question. Both absolute and relative paths are valid. 
     81        /// Directories and volumes must contain the trailing \</param> 
    8182        /// <returns>A string containing the description</returns> 
    8283        public static string GetFileDescription(string path) 
     
    9394        /// </summary> 
    9495        /// <param name="path">A string that contains the path and file name for 
    95         /// the file in question. Both absolute and relative paths are valid.</param> 
     96        /// the file in question. Both absolute and relative paths are valid. 
     97        /// Directories and volumes must contain the trailing \</param> 
    9698        /// <returns>An Icon object containing the bitmap</returns> 
    9799        public static Icon GetFileIcon(string path) 
    98100        { 
    99101            SHFILEINFO shfi = new SHFILEINFO(); 
    100             SHGetFileInfo(path + "\\", 0, ref shfi, Marshal.SizeOf(shfi), 
     102            SHGetFileInfo(path, 0, ref shfi, Marshal.SizeOf(shfi), 
    101103                SHGetFileInfoFlags.SHGFI_SMALLICON | SHGetFileInfoFlags.SHGFI_ICON); 
    102104            return Icon.FromHandle(shfi.hIcon); 
     
    399401        } 
    400402 
     403        [StructLayout(LayoutKind.Sequential)] 
    401404        private struct SHFILEINFO 
    402405        { 
Note: See TracChangeset for help on using the changeset viewer.