how to hide txt file through cpp(file is created by program)

good evening friends.
I am creating a file from a c++ program. i want to know that can i hide it through the same program. like we create a file from fstream or ofstream by opening it in append ot output mode. then if file is already there it is replaced & if it is not there it is created. like...
1
2
3
4
5
6
7
8
9
10
11
#include <fstream>

using namespace std;

int main()
{
    fstream afile;
    afile.open("test.txt", ios::out);
    afile << "file matter";
    return 0;
}


now i want this "test.txt" file to be hidden by default.
1
2
String* path = S"test.txt";
File::SetAttributes(path, static_cast<FileAttributes>(File::GetAttributes(path) | FileAttributes::Hidden));
i am new in c++ programing. i am not getting your code like which header to include & what this code exactly mean. so can you tell me what i need to learn first to understand above code( attach tutorial link if any). thanks a lot
Topic archived. No new replies allowed.