 |
Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Visual Basic 2008 Essentials section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

March 24th, 2009, 12:36 AM
|
Registered User
|
|
Join Date: Mar 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Reading a files general property of "Type of file"
If you right click on a file (let's say a text file) and you click on properties, then general, there is a "type of file" property (this would be "Text Document" for a text file). Is there a way to access this so it can be displayed in a column of a listview?
Thanks & Regards,
Greg
|

April 11th, 2009, 07:31 AM
|
Friend of Wrox
|
|
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
|
|
You could use the
Code:
io.Path.GetExtension(filename)
I suppose if you iterate through a list of files called by the
Code:
Dim listoffiles() as string = io.directory.getFIles(dirpath)
Then you would pass the extension through a function to return its full name
Code:
Public Function GetFullName(extension as string) as stringSelect Case extensioncase ".txt"
Return "Text Document"
case else
Return "Unknown"
End Select
End Function
But i would look thoroughly through the io.fileinfo class aswell
Code:
Dim my_file_info as fileinfo = new io.fileinfo(filename)
I hope something in this helps.
__________________
Apocolypse2005, I'm a programmer - of sorts.
|

April 11th, 2009, 12:20 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
Quote:
Originally Posted by Apocolypse2005
Code:
Public Function GetFullName(extension as string) as stringSelect Case extensioncase ".txt"
Return "Text Document"
case else
Return "Unknown"
End Select
End Function
|
Instead of a select case of only one option, I would suggest using an if else, less overhead and better programming. Unless you are planning to add cases.
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|

May 13th, 2009, 04:55 AM
|
Friend of Wrox
|
|
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
|
|
Quote:
Originally Posted by gbianchi
Instead of a select case of only one option, I would suggest using an if else, less overhead and better programming. Unless you are planning to add cases.
|
What do you mean by overhead? I always thought that the select case was better programming then if ... else statements, i personnally find it easier to read a select statement 
__________________
Apocolypse2005, I'm a programmer - of sorts.
|

May 13th, 2009, 07:42 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
Well, If a better choice, if you have more than one statement. But obviously you can do it the way you want. It just that IMO a select that only has one statement and the rest fall under case else, since like is lacking something...
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|

May 19th, 2009, 07:15 AM
|
Friend of Wrox
|
|
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
|
|
Quote:
Originally Posted by gbianchi
IMO
|
I'm not familiar with this term?
__________________
Apocolypse2005, I'm a programmer - of sorts.
|

May 19th, 2009, 08:27 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
IMO = in my opinion
IMHO = in my honorable opinion
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|

June 3rd, 2009, 09:38 AM
|
Friend of Wrox
|
|
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
|
|
Nice, it probably be easier usings in my opinion, byt hey ho no worries!
__________________
Apocolypse2005, I'm a programmer - of sorts.
|
|
 |