Environment.CurrentDirectory Water and Visual Studio read file in different folder

(xiaoguang) #1

Hi,

for example these codes:

var file_Path: String := String.Format(’{0}\Log.txt’, Environment.CurrentDirectory);
using sr := new StreamReader(file_Path) do begin

If I debug in Water, it will look for the Log.txt in:

C:\Program Files (x86)\RemObjects Software\Elements\Bin

However, if I debug in Visual Studio 2019, it will look for the Log.txt in:

D:\Visual Studio 2019\Projects\Remobjects\Oxygene\ConsoleApplication\Bin\Debug

I think Water should look for this file as the path in VS.

Regards,
Xiaoguang

0 Likes

(marc hoffman) #2

Do you have a Working Directory set in project settings? Water honors that.

0 Likes

(xiaoguang) #3

Which one is the “Working Directory”? Do you mean the “Output path”? I didn’t change the default value

0 Likes

(marc hoffman) #4

no, Working Directory:

you might need to turn on Show Advanced Project Settings in the Preferences.

I will change Water/the debugger to use the folder containing the executable by default, if no Working Directory is set.

0 Likes