Storing file to specific directory

Hello, I am attempting to write a file to a specific directory using:

fstream myFile("c:\\Windows\\file.txt", ios::out | ios::app);.

When I execute the program, the file is saved in: C:\Users\Name\AppData\Local\VirtualStore\Windows instead. The program's working directory is C:\cplusplus\filewriter

I am working on a 64 bit vista OS. I am compiling with MSVC++

I have also tried using:

fstream myFile("c:/Windows/file.txt", ios::out | ios::app);.

The file will write properly to my working directory if I only use the filename, "file.txt".


Thanks in advance for any replies.
You seem to be using Windows Vista, or maybe Windows 7. You are experiencing file system virtualization. If you want to avoid it and get the file inside C:\Windows, you must run your application with elevated privileges.
I am running the application as an administrator, is this a different type of thing than 'elevated settings'?

I am working on a 64 bit vista OS.

Until I get/learn to install and use linux, as Vista has been nothing but a problem and a perfect example of how not to write a good operating system.
Apparently Vista for some reason does not run applications as an administrator by default, even when the user is logged in as an administrator. Thanks for the hint.

I beg to differ. Windows Vista is excellent in my opinion, and Windows 7 by extension. Windows 7 administers RAM better, and maybe other system resources.

The problem is the programmers (sorry to say) like you. Windows Vista requires elevation to protect the operating system from harm. There are PLENTY of ways to share data among users if that is your goal, primarily the Public folders.

Just because you don't know how the operating system works doesn't mean that it is crap. Get a good book about Windows Programming and you'll change your sentiment about this wonderful operating system.
Usually neither Windows or Linux run programs as administrator / root for default - depending on version, distro, etc... -
I suppose I should clarify my dissatisfaction with Windows. I am fully aware that I lack any programming experience/know how to criticize anything for it not being/being a good/bad environment for programming. My complaint regarding Vista is its resource intensity and several bugs that occur from time to time that annoy me, not its impact on anyone's ability to write software.

Perhaps to say ''how not to write an OS" is over the top, for that I apologize.

Thanks again for the replies.
LOL! Maybe I also need to apologize. I know that my reply sounded harsh towards you. It was never personal. I just used a facet of you (the programmer facet) as an example of what people in general out there do.

So I just wanted to assure you that it wasn't personal. I like Windows, and I sure defend it, but I didn't create it, and I certainly don't earn a dime on its sales, therefore you insulting Windows is never an insult to me. I just "illuminate" people whenever I hear misconceptions about the OS.
No sweat. I'm pretty difficult to offend, and surely wouldn't be over a discussion on programming.

I know very little about the subject, and have much to learn. Windows is the commercial standard OS for a reason.

Although I am legitimately interested in what all the buzz is about linux seemingly being geared towards programmers - as I read this almost every time I research anything related to programming.
closed account (z05DSL3A)
If you PC has the power, I would recommend getting somthing like VirtualBox[1] and installing Linux in it. You will be able to investigate it with no real impact on your system.

I don't dislike Microsoft but I am getting disenchanted with them. Vista has never impressed me, at least not enough to make me want to move away from XP.

[1] http://www.virtualbox.org/
Thanks Grey Wolf, I will definitely check that out.
Not sure how much you know about different linux distributions, but in my humble opinion, starting out with Ubuntu ( www.ubuntu.com/ ) is probably a good idea, then when/if you feel like you're being held back you can upgrade to something like Fedora ( fedoraproject.org/ ).

Like Grey Wolf said, check out virtualbox, try a few different distro's and see how you go

good luck :)
Topic archived. No new replies allowed.