A similar problem exists when using Environment.CurrentDirectory
as the current directory is not necessarily the folder in which your application resides. You can test this yourself by creating a console application containing the following code:
public static void Main(string[] args)
{
Console.WriteLine("Current Directory: " + Environment.CurrentDirectory.ToString() );
Console.WriteLine("Press any key to continue...");
Console.ReadKey( true );
}
Now if you run the code, it does as you would expect. But if you open your applications folder in explorer then right-click and 'create a shortcut', you can edit the properties of the shortcut and change the 'Start in' parameter to 'C:\'. When you then run the application using the shortcut, the current directory is set to 'C:\' and not that of your application. Please see my previous post for the correct method.
Regards Wayne Phipps ____________ Time is the greatest teacher... unfortunately, it kills all of its students View my Blog