Rekha - Thursday, April 11, 2013 7:53 AM:
Hi,
Can anyone help me with the code to upload a file available in ARAS to a share point library( like account:2222/.../)
Thank you.
Regards
Rekha
vasant - Friday, April 12, 2013 1:43 AM:
Hi Rekha,
Paste Microsoft.SharePoint DLL into folder "C:Program FilesArasInnovatorInnovatorServerin"
Write Server side code to download the File (existing into Aras to C:)
After downloading that file upload that file into Sharepoint using below code.
// Getting a reference to the document library
SPSite sp = new SPSite("account:2222");
SPWeb site = sp.OpenWeb();
SPFolder folder = site.GetFolder("Documents");
SPFile files = folder.Files;
// Opening a filestream
FileStream fStream = System.IO.File.OpenRead("C:MyDocument.doc");
byte[] contents = new byte[fStream.Length];
fStream.Read(contents, 0, (int)fStream.Length);
fStream.Close();
// Adding any metadata needed
Hashtable documentMetadata = new Hashtable {{"Comments", "MyDocument Comment"}};
// Adding the file to the SPFileCollection
SPFile currentFile = files.Add("Documents/MyDocument.docx", contents, documentMetadata, true);
site.Dispose();
sp.Dispose();
Thanks- Vasant PADHIYAR
Rekha - Friday, April 12, 2013 6:45 AM:
Thank you Vasant. This should help.
Can you clarify on the authentication required?
ARAS has to be accessed on the same server where the Sharepoint is available. And hence windows authentication is the only way here.
I cannot develop the code on my localhost which is not connected to the sharepoint server.
Regards
Rekha