Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Trouble with opendialog and saving data to a file

CobolCobol Member Posts: 9
I'm writing a program and I need to store some data in a binary file. I want to create this file in the same folder where the program is being run. The problem is that I need to store some paths to files chosen by the user. When the opendialog to choose these files is executed and you choose a file, the configuration file I want to use is created in the same folder where the file chosen in the opendialog is located, but not in the folder that contains the program. So it creates a new file instead of use the existing one in the program folder.

How can I tell the program that it musts write the file in the same folder where it's located?
Thanks.

Comments

  • ManningManning Member Posts: 1,621
    : I'm writing a program and I need to store some data in a binary file. I want to create this file in the same folder where the program is being run. The problem is that I need to store some paths to files chosen by the user. When the opendialog to choose these files is executed and you choose a file, the configuration file I want to use is created in the same folder where the file chosen in the opendialog is located, but not in the folder that contains the program. So it creates a new file instead of use the existing one in the program folder.
    :
    : How can I tell the program that it musts write the file in the same folder where it's located?
    : Thanks.
    :

    ExtractFilePath(ParamStr(0)) will give you the directory of the currently running program. So just use ExtractFilePath(ParamStr(0)) + 'CONFIG.CFG'; or something similar.
  • CobolCobol Member Posts: 9
    Thank you. It solved the problem, now it works right.

    : : I'm writing a program and I need to store some data in a binary file. I want to create this file in the same folder where the program is being run. The problem is that I need to store some paths to files chosen by the user. When the opendialog to choose these files is executed and you choose a file, the configuration file I want to use is created in the same folder where the file chosen in the opendialog is located, but not in the folder that contains the program. So it creates a new file instead of use the existing one in the program folder.
    : :
    : : How can I tell the program that it musts write the file in the same folder where it's located?
    : : Thanks.
    : :
    :
    : ExtractFilePath(ParamStr(0)) will give you the directory of the currently running program. So just use ExtractFilePath(ParamStr(0)) + 'CONFIG.CFG'; or something similar.
    :

Sign In or Register to comment.