Unathorized for write a file (xml) into install path

Add-in Express™ Support Service
That's what is more important than anything else

Unathorized for write a file (xml) into install path
Unathorized for write a file (xml) into install path 
GabrielMA




Posts: 15
Joined: 2014-05-14
Hi,

I developed the add-on and then I did the setup file.
When I tried to execute the add-on in Explorer I have a problem writting a file into the install add-on path.

path: C:\Program Files\XXX
I obtain the path like this:
string codeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
FileInfo fileinFo = new FileInfo(codeBase.Replace("file:///", String.Empty));
this.configFolder = fileinFo.Directory.FullName.ToString();

exception: UnauthorizedAccesException

Could you tell me how save file in this path without throw the exception?
How I can give permissions to the add-on so I can write in this directory?

Thanks.
Posted 16 Jul, 2014 03:40:31 Top
Andrei Smolin


Add-in Express team


Posts: 14094
Joined: 2006-05-11
Gabriel,

Please check HowTo: Deal with Protected Mode API in Internet Explorer.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 16 Jul, 2014 06:35:00 Top
GabrielMA




Posts: 15
Joined: 2014-05-14
Good morning Andrei Smolin,

I have reviewed reference http://www.add-in-express.com/creating-addins-blog/2009/06/12/internet-explorer-protected-mode-api/ for writing files in protected mode. I can´t see how to implement exactly what I want. I mean…
What I want to do is to write an xml.

if (instance.GetFileLocked() == 0)
{
instance.SetFileLocked(1);
try
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
XmlWriter writer = XmlWriter.Create(this.configurationData.GetConfigFilePath(), settings);
// this.configurationData.GetConfigFilePath() This is a pre define path. I do not need SaveFileDialog
writer.WriteStartDocument();
writer.WriteComment("Configuracion de plugin IE");
writer.WriteStartElement("Config");
writer.WriteElementString("started", this.configurationData.Started.ToString());
writer.WriteElementString("automaticchek", this.configurationData.IsAutomaticChek.ToString());
writer.WriteElementString("intervalchek", this.configurationData.IntervalChek.ToString());
writer.WriteElementString("lastclean", this.configurationData.LastClean.ToString());
writer.WriteElementString("serviceendpoint", this.configurationData.ServiceEndPoint.ToString());
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
finally
{
instance.SetFileLocked(0);
}
}

How could I do this in protected mode? I have studied the reference you provided me, but I don’t know how adapting it to do what I need.

What “state” must I add to the invoke to save the file using ADXIEProtectedModeAPI?
AddinExpress.IE.ADXIEProtectedModeAPI AddinExpress.IE.ADXIEProtectedModeAPI protectedModeAPI = new ();
protectedModeAPI.SaveFile (?????, tmpFilePath);
The final file path is pre define. I do not need to use SaveFileDialog.

Thanks and best regards,
Gabriel.
Posted 18 Jul, 2014 02:58:46 Top
Andrei Smolin


Add-in Express team


Posts: 14094
Joined: 2006-05-11
Hello Gabriel,

I see. Writing to Program Files is disabled for a standard user by default. You need to contact an administrator if you really need your users to be able to write to this folder. Typically, configuration information is user-specific and it can be stored in the user's profile.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 18 Jul, 2014 08:07:25 Top
GabrielMA




Posts: 15
Joined: 2014-05-14
Hi Andrei,

Thanks for the information. With this I managed the add-on.

Thanks and best regards,
Gabriel.
Posted 24 Jul, 2014 07:17:25 Top