scope of getcurrentdirectory - TechRepublic
General discussion
December 16, 2005 at 08:50 AM
ladyreader

scope of getcurrentdirectory

by ladyreader . Updated 20 years, 6 months ago

My VB.net program reads in some constant data from a text file. I navigate to this file by setting a relative path, which I intended to wrok both on my pc, with my file structure, and in prod :

Dim path As String = Directory.GetCurrentDirectory
Dim parent As System.IO.DirectoryInfo = Directory.GetParent(path)

Dim FOLDER_PATH As String = parent.ToString & ConfigurationSettings.AppSettings(“PrefixAndSuffixFilePath”)

The config file entry points to the file name.
This works fine on my pc from the IDE but when I trigger the executable from a cmd file on the prod server it fails to find the required file.

Research showed that in prod path = C:\Windows and Parent = C:\

Obviously getcurrentdirectory is acting differently in the prod environment. Can anyone tell me what’s going on or suggest an alternate method of providing a relative path? I would prefer not to hardcode the path to the text file.

Thanks!

This discussion is locked

All Comments