Discussion Locked

scope of getcurrentdirectory

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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!

2 replies

by lowlands

Some probably silly suggestions/questions:
Does prod have same .NET runtime as your workstation (CE .NET does not support getcurrentdirectory).

Is the config file in the right location?

Do you run the file from the same location on your workstation as in prod.

can you create a small test exe. Just one button and three labels showing you the value for path, parent and current_folder

by lowlands

Some probably silly suggestions/questions:
Does prod have same .NET runtime as your workstation (CE .NET does not support getcurrentdirectory).

Is the config file in the right location?

Do you run the file from the same location on your workstation as in prod.

can you create a small test exe. Just one button and three labels showing you the value for path, parent and current_folder

This discussion is closed to new replies.