I have a problem with opening file in non-shared mode on Windows 2008 server using ifstream object. My code works fine on Windows XP, but as soon as I try to run it on Windows 2008 Server, the file open fails with errno value 13 (permission denied). I have "Full Control" rights over the file and the folder containing the file. The file is not open by any other users, as it can be renamed and moved to the other folder. In case of both operating systems the file is located on a local drive, not on a network share. The line in my code opening the file is as follows:
inpfile.open (ifname, ios::in | ios::binary, filebuf::sh_none);
where inpfile is an object of class ifstream.
If I remove the "filebuf::sh_none" parameter, it works fine also on Windows 2008. However, I would like to make sure that no one else is accessing the file at the same time (so I need the exclusive mode), that's why I used protection specification sh_none.
What could be the possible reason of such behaviour? Does someone have the same experience?
I am using the old Microsoft Visual C++ 6.0 - perhaps it's just too old to compile a program to be used on Windows 2008...
I would be happy if someone could share some experience. Thanks in advance!