Search code examples
c++-cli

C++/CLI StreamWriter cannot specify path


i' m trying to make loginapp in c++/cli with users data log. I would use fstream but it isnt possible in cli. So I use StreamWriter and i cant specify totally normal path C:\log.txt (also tried) C:\\log.txt And when i debug my programme i get error 'access is denied' but also i have this problem when i run it like an admin. However when I just specify it like a log.txt it works and the file is being maked in vs project folder and its not satisfying for me. I paste my code below.

        StreamWriter^ log = gcnew StreamWriter("C:\log.txt", true);
        log->WriteLine(newLogin);
        log->WriteLine(newPassword);
        log->Close();
        label7->Visible = true;

I also tried a method with @ operator but it also doesnt work. Sorry for my english.


Solution

  • C:\ is a path with admin permissions required. Try launching Visual Studio as administrator or change your path to some other which does not need them.