|
-
Jul 24th, 2008, 09:49 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] File Type Info
I'm having trouble getting a files description...
ie
".txt" = "Text Document"
I do not want to use a registry lookup, as i doubt this is the way other programs do it ... i don't find it to be very efficient...
Does anyone know any other ways of doing this?
e.g.
Code:
lvitem.SubItems.Add(System.IO.File.GetAttributes((MyFiles(i))).GetType)
^
|
Doesn't work
-
Jul 24th, 2008, 09:56 AM
#2
Re: File Type Info
GetType is a method used to get the actual .NET framework type of a given object.
File extension descriptions are in fact stored in the registry, and that is how you should go about retrieving them.
How is it not very efficient to use the registry for this?
-
Jul 24th, 2008, 10:09 AM
#3
Thread Starter
Hyperactive Member
Re: File Type Info
Well I had a quick browse through the CLASSES_ROOT node and tried to find, BMP for bitmap
found
".bmp"
description
"Paint.Picture"
Although when I right click > properties > Type Of File
it says
"Bitmap Image"
2 totally different descriptions ... so I'm just wondering where does the file properties window get its info from? and can I use it?
-
Jul 24th, 2008, 10:37 AM
#4
Re: File Type Info
what about this?
Code:
Dim myExtensionToFind As String = ".bmp"
Dim myExtensionType As String = My.Computer.Registry.GetValue("HKEY_CLASSES_ROOT\" & myExtensionToFind, String.Empty, String.Empty).ToString
Dim myExtensionDescription As String = My.Computer.Registry.GetValue("HKEY_CLASSES_ROOT\" & myExtensionType, String.Empty, String.Empty).ToString
MessageBox.Show(String.Format("File Type {0} is : {1}", myExtensionToFind, myExtensionDescription))
-
Jul 24th, 2008, 10:58 AM
#5
Thread Starter
Hyperactive Member
Re: File Type Info
the myExtensionDescription always draws a blank :S for some reason mate?
-
Jul 24th, 2008, 11:01 AM
#6
Re: File Type Info
 Originally Posted by boku
the myExtensionDescription always draws a blank :S for some reason mate?
Can you give an extension example that Klienma's code would return a blank description?
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Jul 24th, 2008, 11:02 AM
#7
Thread Starter
Hyperactive Member
Re: File Type Info
Nevermind, just had to move stuff around bit.
Excellent work as usual Klienma 
I eat my words
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|