Mega Code Archive

 
Categories / VB.Net Tutorial / Collections
 

Get and set the current directory

Imports System.IO public class Test    public Shared Sub Main         Console.WriteLine("Current directory is " & Directory.GetCurrentDirectory & ".")         Try             Directory.SetCurrentDirectory("..\..\..\..\..\Temp")             Console.WriteLine("Switched current folder to " & _                Directory.GetCurrentDirectory & ".")         Catch exc As FileNotFoundException             Console.WriteLine("Invalid folder specified, currrent directory is " & _                vbCrLf & Directory.GetCurrentDirectory & ".")         Catch exc As Exception             Console.WriteLine("Can't access the specified folder.")         End Try    End Sub End class Current directory is C:\Java_Dev\WEB\dev\VB. Switched current folder to C:\Temp.