i have an InfoPath 2007 file which includes code to generate a signed PDF out of the current infopath form. Now i want to upload this PDF via C# code into a sharepoint 2010 library.
SPSite objSite = new SPSite(spSite); SPFolder objFolder = objSite.OpenWeb().GetFolder(spLibraryName); string sourcePath = document; FileInfo fi = new FileInfo(sourcePath); int fileSize = (int)fi.Length; SPFileCollection objFiles = objFolder.Files; byte myFile = new byte[fileSize]; FileStream mystream = new System.IO.FileStream(sourcePath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); mystream.Read(myFile, 0, fileSize); mystream.Close(); string strFileUrl = document; SPFile spf = objFiles.Add(strFileUrl, myFile);
but it did not work because the SPSite could not be created /found.
Now i want to know if it is possible to use a dataConnection to put the PDF-file through.
How can i solve this?
thank you, el