c++ - File I/O
- Erik Weber (14/14) May 12 2012 Can someone tell me how to create a file within a directory such
- Walter Bright (3/17) May 12 2012 Just build a string that includes the path and the file name, and pass i...
- Erik Weber (8/17) May 13 2012 and pass it to
Can someone tell me how to create a file within a directory such as the user's home directory, or a directory within "Program Files", with DMC 852? I cannot get SHGetFolderPath or SHGetKnownFolderPath to compile. Does DMC support those? I can create a file with ofstream.open, but only in the working directory. I don't know how to prepend a path that comes from an environment variable or by querying the system for something like CSIDL_PROGRAM_FILES or what have you, only a hardcoded path. And as far as I know you can't use stuff like getpwuid on Windows. I just want to create a config file for read/write by the executable. Thanks, Erik
May 12 2012
On 5/12/2012 1:58 PM, Erik Weber wrote:Can someone tell me how to create a file within a directory such as the user's home directory, or a directory within "Program Files", with DMC 852? I cannot get SHGetFolderPath or SHGetKnownFolderPath to compile. Does DMC support those? I can create a file with ofstream.open, but only in the working directory. I don't know how to prepend a path that comes from an environment variable or by querying the system for something like CSIDL_PROGRAM_FILES or what have you, only a hardcoded path. And as far as I know you can't use stuff like getpwuid on Windows. I just want to create a config file for read/write by the executable. Thanks, ErikJust build a string that includes the path and the file name, and pass it to fopen().
May 12 2012
== Quote from Walter Bright (newshound2 digitalmars.com)'s articleOn 5/12/2012 1:58 PM, Erik Weber wrote:suchCan someone tell me how to create a file within a directoryand pass it toas the user's home directory, or a directory within "Program Files", with DMC 852? Thanks, ErikJust build a string that includes the path and the file name,fopen().Thanks Walter. It works. What I was unsure of was how to build the string. For now I am using getenv. Apparently the preferred way on Windows is SHGetKnownFolderPath in case environment variables don't work. Erik
May 13 2012