Monday, August 22, 2005

Getting the volume label in .Net

To get the volume label of a particular drive, use the Dir method in the VisualBasic namespace. Note that you can ONLY use the Volume fileattribute if you want to get the volume name. Use of any other attribute will prevent the volume label from being returned. On my system, the DVD drive is my E:\, so the following statement successfully returned the volume label for me:

'Get the CD/DVD volume label
Dim VolumeLabel As String = _
Microsoft.VisualBasic.Dir("E:\", FileAttribute.Volume)


Joe Kunk

Sunday, August 21, 2005

Please feel free to comment on my posts

I just changed the settings on this blog to allow comments by anyone, not just members of blogger.com. I want to encourage comments. If you read one of my posts and have anything to add, please do so. I look forward to the dialog.

Joe Kunk

Using IO.Directory.GetFiles with a filename wildcard

I got an "Illegal characters in path" error on the following statement:
Dim TxtNames As String() = IO.Directory.GetFiles("c:\temp\*.txt")
and from the documentation it was not clear to me why I was getting the error.

Turns out that you must use the second overload version of the GetFiles method with two strings if you want to include a wildcard.

In the example above, the two possible correct versions of the GetFiles method include:

Dim TxtNames As String() = IO.Directory.GetFiles("c:\temp")
Dim TxtNames As String() = IO.Directory.GetFiles("c:\temp","*.txt")

The second statement provides the desired result of returning a string array of all filenames with a txt extension in the c:\temp folder. The first statement returns all files in the c:\temp folder which can be scanned with a loop for further processing.

Note that the single string overload verison of GetFiles can only accept a directory name.

I hope this helps clarify a point that managed to confuse me. As usual, it's obvious once you know the answer!

Joe Kunk

Friday, August 19, 2005

GLUGnet Presentation 08-18-05

Last night I gave the feature presentation to GLUGnet, the Greater Lansing User Group for .Net. The topic was language enhancements and conversion recommendations for Visual Basic 2005. The Powerpoint presentation is available for free download at http://portal.artemis-solutions.com/glugnet/go/iris/3373/en-US/DesktopDefault.aspx. Download the file named, "GLUGnet August 18, 2005.zip".

There was an error on the example for the CONTINUE statement which has been corrected.

The Internet web address for all the sites I mentioned at the GLUGnet meeting were added as the last slide of the presentation.

Thank you to GLUGnet for allowing me to give this presentation. I learned a lot by doing the research for the presentation and I really enjoyed the experience. GLUGnet is a great user group and I'm very proud to be a part of it.

If you find yourself in the East Lansing Michigan area on the third Thursday of the month, please feel free to join us for free food and drinks and an educational meeting. See the web site http://www.glugnet.org for more information.

Joe Kunk

Thursday, August 11, 2005

Two VB.NET blogs you don't want to miss

Today I ran across two blogs about Visual Basic that are awesome resources.

The first is the blog from the Visual Basic .Net IDE team. From their introduction, "This blog is hosted by the program managers, developers, and testers who work on the Visual Basic Integrated Development Environment (VB IDE). " This blog has an awesome FAQ and further tips on the cool new feature of Code Snippets. Other topics include code generation for overrides, a snippet editor, refactoring tool, new debugger features, and an awesome list of the 10 best new features in Visual Basic 2005. It can be found at http://blogs.msdn.com/vbide/default.aspx

The second is "Don't be Iffy" by Julie Lerman. This is a extensive informal blog by a self-employed programmer who clearly loves programming and Visual Basic.Net. Her personality really comes through on her blog. I think you will find it both informative and enjoyable. http://www.thedatafarm.com/blog/

Joe Kunk