x< Visual Basic X Zone - information about Visual Basic and Visual Basic.NET
         

Our first .NET article!

vbXzone is happy to bring you .NET development information. All .NET languages (Managed C++, C#, VB.NET, J#) are somewhat all equal in power that they bring to a developer. So we picked VB.NET be our coding language here, although almost always (with minor tweakings) concepts apply to all .NET languages. So please enjoy when we introduce article #1 in .NET series.

How to use File class

File class is a simple and quite useful class contained in System.IO namespace. All of the methods in that class are static, thus you don't need to have an instance of this class to use it. For example, let's look at very useful method of File class called Exists. It's very convenient when you want to check if a file really exists. Just provide a path of the file and if it does exist, Exists method will return true, otherwise it will return false, like this:

....
If System.IO.File.Exists( "c:\test.txt" ) Then
    Console.WriteLine("Yes, it exists")
Else
    Console.WriteLine("No, it doesn't exist")
End If


Simple enough. If you don't want to call System.IO.File.somemetodname, just add Imports System.IO statement before any class or module declarations in your .vb file (that's where VB.NET code resides now) and you can call the statement in the example like this: File.Exists("c:\test.txt").
Here is more operation you can do with File class ( for more info on these operations, please reffer to MSDN website at msdn.microsoft.com):Create a file, Delete a file, get or set attributes of the file, get or set creation time, get or set last access time, last write time, creation time. Pretty useful class.

So this is our first (and short) article on .NET. If you have any suggestions, questions or requests of topics you would like us to discuss here, please email them to vbxzone@yahoo.com  

Written By Laimonas Simutis. 2002. laijerrad@yahoo.com