0

I need help creating a Folder in AppData. Lets say I want to create a Folder in %appdata% called "MyFolder", which has the text file test.txt I tried to use <fstream> and do this;

ofstream file("%appdata%\MyFolder\test.txt");

but it didn't work..

halfer
  • 19,824
  • 17
  • 99
  • 186
snivy9014
  • 418
  • 1
  • 4
  • 14

1 Answers1

3

Things like %appdata% are OS specific, and Standard C++ has no direct means of dealing with them. You will have to write code to parse the file path, and extract values like %appdata% from the environment, or alternatively use non-standard functions to open the file, should such exist.

P.S. It also wouldn't work because "\" escapes the quotes, do "\\" instead.

Community
  • 1
  • 1