Thread overview | |||||
---|---|---|---|---|---|
|
May 12, 2012 File I/O | ||||
---|---|---|---|---|
| ||||
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 13, 2012 Re: File I/O | ||||
---|---|---|---|---|
| ||||
Posted in reply to Erik Weber | 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,
> Erik
Just build a string that includes the path and the file name, and pass it to fopen().
|
May 13, 2012 Re: File I/O | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | == Quote from Walter Bright (newshound2@digitalmars.com)'s article > 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? > > > > Thanks, > > Erik > Just build a string that includes the path and the file name, and pass it to > 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 |
Copyright © 1999-2021 by the D Language Foundation