<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: FormsService UploadFormTemplate Method throws Access denied error</title><link>https://www.infopathdev.com:443/forums/thread/74964.aspx</link><pubDate>Mon, 06 Feb 2012 03:32:58 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:74964</guid><dc:creator>kannabirank</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/74964.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=74964</wfw:commentRss><description>&lt;p&gt;Hi Jimmy,&lt;/p&gt;
&lt;p&gt;Could you tell me how to give permission to the process for that folder?&lt;/p&gt;</description></item><item><title>Re: FormsService UploadFormTemplate Method throws Access denied error</title><link>https://www.infopathdev.com:443/forums/thread/74963.aspx</link><pubDate>Mon, 06 Feb 2012 02:58:14 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:74963</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/74963.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=74963</wfw:commentRss><description>&lt;p&gt;Ok, and are you saying that the code works in loading the template from C:\Users\Administrator\AppData\Local\Temp\expensereport.xsn when you run it from the console, but not in a webpart?&amp;nbsp; I&amp;#39;d think it&amp;#39;s very likely that the ShP server process wouldn&amp;#39;t have access to the Administrator temp folder.&lt;/p&gt;</description></item><item><title>Re: FormsService UploadFormTemplate Method throws Access denied error</title><link>https://www.infopathdev.com:443/forums/thread/74962.aspx</link><pubDate>Mon, 06 Feb 2012 00:07:45 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:74962</guid><dc:creator>kannabirank</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/74962.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=74962</wfw:commentRss><description>&lt;p&gt;Console.ReadLine() is just an example. Ignore that line.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not&amp;nbsp;sure if I need to run this code with farm admin privilege within my web application???&lt;/p&gt;</description></item><item><title>Re: FormsService UploadFormTemplate Method throws Access denied error</title><link>https://www.infopathdev.com:443/forums/thread/74957.aspx</link><pubDate>Sun, 05 Feb 2012 20:30:15 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:74957</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/74957.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=74957</wfw:commentRss><description>&lt;p&gt;I haven&amp;#39;t used this web service, and I don&amp;#39;t know if it&amp;#39;s the cause of your issue, but does that Console.ReadLine() need to be there?&amp;nbsp; Would it accomplish anything in your webpart?&lt;/p&gt;</description></item><item><title>FormsService UploadFormTemplate Method throws Access denied error</title><link>https://www.infopathdev.com:443/forums/thread/74954.aspx</link><pubDate>Sat, 04 Feb 2012 14:31:56 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:74954</guid><dc:creator>kannabirank</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/74954.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=74954</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;I&amp;#39;m trying to programmatically upload an forms template using the following code. If I run the code in a console application it works fine but the same code is not working if I execute under sharepoint context through Webpart code. I&amp;#39;m getting System.SecurityException&amp;nbsp;&lt;strong&gt;access denied&lt;/strong&gt; error. I&amp;#39;m running the code with elevated priveleges.&amp;nbsp;The form template file is first downloaded to a temp folder(c:\users\administrator\AppData\Local\Temp) and then I&amp;#39;m uploading the file from this path. thanks in advance for your reply.&lt;/p&gt;

&lt;p&gt;
FormsService localFormsService; &lt;br /&gt;
SPFarm localFarm = SPFarm.Local;&lt;br /&gt; 
Int16 formTemps; &lt;br /&gt;
 
try &lt;br /&gt;
{ &lt;br /&gt;
FormTemplate temp = new FormTemplate(); &lt;br /&gt;
localFormsService = localFarm.Services.GetValue (FormsService.ServiceName); &lt;br /&gt;
            localFormsService.FormTemplates.UploadFormTemplate 
(@&amp;quot;C:\Users\Administrator\AppData\Local\Temp\expensereport.xsn&amp;quot;); &lt;br /&gt;
Console.ReadLine(); &lt;br /&gt;
} &lt;br /&gt;
catch (Exception ex) &lt;br /&gt;
{ &lt;br /&gt;
Console.WriteLine(&amp;quot;Error: &amp;quot; + ex.Message); &lt;br /&gt;
Console.Write(&amp;quot;Press Enter to Continue&amp;quot;); &lt;br /&gt;
Console.ReadLine(); &lt;br /&gt;
} &lt;br /&gt;
&lt;/p&gt; &lt;br /&gt;</description></item></channel></rss>