General discussion

Locked

scope of getcurrentdirectory

By LadyReader ·
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 conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by lowlands In reply to scope of getcurrentdirect ...

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

Collapse -

by lowlands In reply to scope of getcurrentdirect ...

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

Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums