Read/write permissions on c:\ProgramData

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Program Add-Ins RSS
Next:  Sum using Vlookup??  
Author Message

Joined: Mar 03, 2008
Posts: 1

PostPosted: Mon Mar 03, 2008 9:55 am    Post subject: Read/write permissions on c:\ProgramData


I've inherited a bit of code and told to get it working. The bones of the code seems to be OK, apart from how the original coder decided to store the add-ins settings.

Basically a folder is got from using My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData (C:\ProgramData on a std Vista install), and there is an xml file placed there during installation which has default settings. The file is read using a data reader's ReadXML method, and elsewhere in the code values are ascertained with .Tables(0).

All looks good!

If I write a stand alone app to do all this, targetting the same file, all goes well, and I can iterate values as needed. If I call WriteXML, I can write as needed.

When I run the code in the context of an addin, the ReadXML doesn't appear to read the file, as .Tables.count returns zero and any attempted call to WriteXML brings a security exception that there aren't rights to the file.

OK, so I check the rights to the folder, Administrators have read/write, Everyone has only read.

In the code, the original author has placed a AppDomain.CurrentDomain.SetPrincipalPolicy(Principal.PrincipalPolicy.WindowsPrincipal) in an attempt to get elevation to perform the required task... but it doesn't appear to be doing the job.

So, basically, I can do what I need to do if the code is being run directly with the users credentials, but when being run in the context of Outlook, it loses rights. I guess this is because the addin inherits its hosts permissions - but is there a way that I can get the permissions I need to deal with the file.

From what I can see the original author has done the responsible things that are recommended for Vista, I've looked around at various posts that searches return, but to no avail.

The code appears to work OK on XP.

Any ideas?

Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Program Add-Ins
Page 1 of 1

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum