Write to Special Folders [C++/CLI]

Jul 12, 2011 at 9:48pm
How do I write files to special folders such as the Program Files.
Jul 13, 2011 at 6:04am
?? Just the same way you would with other folders, except that your program needs the special rights: Either the folder allows regular users write access, or your program runs as admin.
Jul 13, 2011 at 12:56pm
I'm on and Admin account and it won't write to Program Files.
Jul 13, 2011 at 1:42pm
Running elevated?
Jul 13, 2011 at 4:30pm
What does "GetLastError()" return to you?

Are you actually entering "C:\Program Files"?

Can we see a section of code?
Jul 14, 2011 at 3:35pm
1
2
3
4
5
6
7
8
			    String^ szGuest_GetFileName = txtbGuestName->Text;                                               //Name the name of the person
				String^ szGuest_FileName = szGuest_GetFileName + ".txt";
				String^ szPath           =  "C:\\Program Files\\Grace_Assembly_Of_God\\";
				
				
				String^ szGuest_FilePath = szPath + szGuest_FileName;
				StreamWriter^ Guest_Records = gcnew StreamWriter(szGuest_FilePath);
		


I know that above it says makes the file, but I tried to remove it on here, but it won't. It's actually the last line that makes the file.
Last edited on Jul 14, 2011 at 3:36pm
Jul 14, 2011 at 6:53pm
C# != C++
Jul 14, 2011 at 7:03pm
closed account (z05DSL3A)
but that is not c#...its C++/CLI...that is still not C++. :0)

Drue, you have not answered webJoses question, are you running with elevated privileges?

Why are you writing into the program files directory? Would it be better to write to CommonApplicationData or ApplicationData?

http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx
Last edited on Jul 14, 2011 at 8:22pm
Jul 14, 2011 at 10:34pm
Sorry, my mistake the first few search results for "StreamWritter()" came back as C#.
Jul 16, 2011 at 1:26am
Sorry, I was out fishing. I don't know how to use elevated privliges. The reason I need it to write to Program Files, is because, I'm going to end up making an Admin thing for it, and I need to be able to write to a solid spot. I'm thinking of writing the output to my documents.
Jul 16, 2011 at 3:40am
Right click - run as administrator or use a manifest to require administrator privileges execution level.
Jul 20, 2011 at 4:35am
I added this line to my manifest

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />


The problem is, even with that enabled, and when i click run as administrator, it still brings up an error box. Right now I have it so you all you need to do is click the work administrator in the menu bar and it creates a file

C:\Program Files\Grace_Assembly_Deployment\Administrator
or something like that.

It makes the file, but it still pulls up the error message. I know there has to be a way to fix this, because some viruses don't even prompt you.

This is the program I'm making.

http://www.megaupload.com/?d=3ZG3T6N8

[EDIT]
It was a stupid, little coding error that the debugger never picked up.
Last edited on Jul 24, 2011 at 3:52am
Topic archived. No new replies allowed.