Monday, July 30, 2007

IronPython/IPCE : Simpler method to get logical drives

The previous enumeration approach allowed you to, as well as getting the drive letters through the "Name" property, also access associated "DriveType" and "MediaType" properties -- effectively between them giving the index of the related Shell32.dll icon. That information, however, seems to be less than useful in the .Net framework without manually unpicking the PE format for the icons. So, you might as well go the direct route like--


System.String[]('C:\\', 'D:\\', 'E:\\', 'F:\\', 'G:\\', 'H:\\', 'I:\\', 'J:\\',
'K:\\', 'L:\\', 'N:\\')

which adds the trailing back-slash; and also has the advantage of working in Mono 1.2.4 with IPCE-r6.

Fortunately Fuzzyman's to do on-the-fly compilation of C# works there too, so I can still get the icons on that platform. Once I've worked around another quirk, that is -- Mono/IPCE is much more rigorous about the .Net types -- I had to explicitly create an Image, rather than use an Icon with implicit toBitmap() conversion in a call to Graphics.DrawImage

Post a Comment