#File not written in a directory

2 messages · Page 1 of 1 (latest)

quiet oasis
#

Hey! this code was supposed to get the username of windows, and get the directory of Desktop with the stored username and write a file.

    std::wstring uname;
    DWORD ulen = UNLEN + 1;
    uname.resize(ulen);
    GetUserName(&uname[0], &ulen);
    std::wcout << L"Username: " << uname << L"\n";
    std::wstring filepath = L"C:/Users/" + uname + L"/Desktop" + L"/gcc.txt";
    std::wcout << filepath;
    std::wofstream filea(filepath);
    filea << L"Hello world!";

    return 0;
} ```

de printing of directory is correct, username is correct but file is not written nor created.

uh thats it..
twilit gyroBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.