How to create files in %appdata% with c++ [duplicate]

好久不见. 提交于 2019-12-12 03:57:01

问题


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..


回答1:


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.



来源:https://stackoverflow.com/questions/42034847/how-to-create-files-in-appdata-with-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!