0

As the title of the post describes, I am attempting save a DataTable straight into a SharePoint Document Library.

Here is what I had originally:

                DataTable dt = new DataTable();

                //add rows to datatable
                foreach(GridViewRow row in Gv.Rows)
                {
                    //omitted for the sake of brevity
                }


                dt.WriteXml("TEMP PATH", true);

However, instead of saving it to a temporary location as an xml file, can I do a sort of all in one where I convert the DataTable into an xml format and upload it to the Document Library? Thanks.

KidBatman
  • 585
  • 1
  • 13
  • 27

1 Answers1

0

You can save the XML file to a temporary location and then save that file to sharepoint document library. AFter the file is uploaded successfully, you can delete the file.

For uploading file : How to download/upload files from/to SharePoint 2013 using CSOM?

How do you upload a file to a document library in sharepoint?

Community
  • 1
  • 1
Aarti
  • 735
  • 5
  • 13
  • Would you advise that I do the above by saving the XML file to a folder in the webpart solution? If so, could you provide me with an example? – KidBatman May 29 '14 at 17:17
  • I would advise you to save the XML file to sharepoint document library. – Aarti May 29 '14 at 17:28
  • To clarify, I mean save the xml file to a folder in the project directory as the temporary location, then send that to the SP doc lib. So save xml to folder in project dir -> send xml to doc lib -> delete xml from folder in project dir. I am currently, having issue trying to find the correct path so I can save said xml to folder in my project. – KidBatman May 29 '14 at 17:52
  • Yes. This is what I am trying to say – Aarti May 29 '14 at 18:10