I am using the following code to open a file in my program.
CString cstrOut; CString cstrFileName; cstrFileName.Format( "FinalSect%1d.txt", nSect+1 ); std::ofstream echofile; echofile.open(cstrFileName);
This works fine but when I open a file without admin rights it can not be opened.
Please help me.
It’s related to User Access Control. A regular user has limited access to C: drive, and Administrator has full access to C: drive (assuming C: is the partition where Windows is installed).
Either make your application register for the UAC (if it is a non trivial application intended for other users, comercial or otherwise) or run Visual Studio (I’m assuming you are using VS, but applies to other IDEs as well) as Administrator (either form context menu, or edit shortcut properties). Or you can work on a different partition than the one where Windows is installed.