Search code examples
formsvisual-studio-2012sharepointoffice365infopath

SharePoint online can't find SPSite, SPWeb, SPFolder


I'm using InfoPath 2012, VIsual studio 2012 and SharePoint online. I'm creating form in infopath that can save files to the SP library, i found this article http://www.bizsupportonline.net/blog/2010/upload-document-sharepoint-infopath-form.htm , I made all like in this article, but I can't connetc to the SPSite, SPWeb, SPFolder. This is the code that makes errors:

 // Add the file to a document library
                using (SPSite site = new SPSite("https://contoso.sharepoint.com/Blog/Shared%20Documents"))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.AllowUnsafeUpdates = true;
                        SPFolder docLib = web.Folders["Documents"];
                        docLib.Files.Add(fileName, data);
                        web.AllowUnsafeUpdates = false;
                        web.Close(); 
                    }
                    site.Close();
                }

Mayby someone have any ideas? I already download the dll library, but it is not help https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM/


Solution

  • You cannot run code behind in an InfoPath form on SharePoint online. You shouldn't use InfoPath at all in SharePoint Online.

    Check this: https://sharepoint.stackexchange.com/questions/56617/can-i-use-infopath-code-behind-in-sharepoint-online