Topic: How to Create Directory in User Documents Folder?

I am trying to create a directory in the users document folder using

procedure Form1_Button5_OnClick (Sender: TObject; var Cancel: boolean);
begin
CreateDir(GetEnvironmentVariable('USERPROFILE')+'\Documents\My Program\Backups');
end;

I have tried several different ways, but cannot accomplish it.  I have no problem writing to the APPDATA Roaming folder, but i want to be able to save some things to my documents for easy access, such as the sqlite.db and the db backups.

Thanks

Sonny.

Re: How to Create Directory in User Documents Folder?

sdhale29,
If both "My Program" and "Backups" directories do not exist then do your create one at a time.

CreateDir(GetEnvironmentVariable('USERPROFILE')+'\Documents\My Program');
CreateDir(GetEnvironmentVariable('USERPROFILE')+'\Documents\My Program\Backups');

Re: How to Create Directory in User Documents Folder?

Thank You ehwagner.  I didn't think to try them one at a time, but it works perfectly.

Sonny.