writting to C:\
Darkmaster (331)
Dec 10, 2012 at 7:43am UTC
I have a problem with missing rights. I just can't create files on C:\. Folders somehow are no problem, but files don't work.
I already tried to run the .exe as an admin, which didn't help.
If anyone knows how to do this, please let me know.
kbw (5374)
Dec 10, 2012 at 12:29pm UTC
You can approach the problems in two ways.
1. Take a look at the permissions at C:\ and see if you have access.
2. Use native WIN32 calls (like CreateFile()), and check your return codes.
You should be able to grant yourself access if you have admin priviledges. However, C:\ is locked down for a reason.
EssGeEich (683)
Dec 10, 2012 at 12:49pm UTC
Can you also show us a little example? All I can say is that Also I had problems with C:, but solved them running the program as admin, thing that doesn't look like it helped you.
SamuelAdams (185)
Dec 10, 2012 at 3:54pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <fstream>
#include <string>
#include <iostream>
using namespace std;
int main()
{
// copy file
std::ifstream src("out.txt" );
std::ofstream dst("c:\\out.txt" );
dst << src.rdbuf();
return 0;
}
Last edited on Dec 10, 2012 at 3:55pm UTC
Darkmaster (331)
Dec 10, 2012 at 4:01pm UTC
does this always work or might i get some problems with it?
modoran (1100)
Dec 10, 2012 at 4:23pm UTC
You need elevated privileges to create files on C:\ drive (or whatever is your windows drive).
Darkmaster (331)
Dec 10, 2012 at 4:28pm UTC
so this is not a programming issue. it's simply a problem of missing rights?
SamuelAdams (185)
Dec 10, 2012 at 4:31pm UTC
how can we know until we see your code ?
Darkmaster (331)
Dec 10, 2012 at 4:37pm UTC
i was asking in general. but if that's your answer, then it is a programming issue.
SamuelAdams (185)
Dec 11, 2012 at 2:59pm UTC
you didn't give us enough info to know if it is or not.