0

Is it possible to create a directory in SharePoint from c# code without using the Microsoft.SharePoint assembly? I would like to create some folders and upload after that few files to them. I think the upload is not the problem. The program should run on a Non-SharePoint machine, so I cannot use the assembly. Any ideas? Greetz.

Edit Or is it possible to add the metadata to the folder, if I create them about the WebDAV of SharePoint?

0

Yes there are a variety of ways. I would recommend using SharePoint's web services and calling the UpdateListItems method. You'd build XML like:

<Method ID="1" Cmd="New">
   <Field Name="ID">New</Field>
   <Field Name="FSObjType">1</Field>
   <Field Name="BaseName">Name</Field>
</Method>

Then, using the C# example at the bottom you can call the webservice.

There are other ways to create folders by using webdav which may be worth investigating.

  • Well, I will have a look tomorrow and gave you feedback, how it works. – user5167 Mar 7 '12 at 15:35
  • A benefit from using web services is that you can add additional Field nodes for your folder's metadata. – Kit Menke Mar 7 '12 at 17:43
  • Does the UpdateListItems method also work for libraries in SharePoint? It sounds like it’s for lists and pages with asmx extension. Greetz? – user5167 Mar 8 '12 at 6:24
  • In addition, does the program run on a pc without SharePoint installation, if I use the SharePoint Services? – user5167 Mar 8 '12 at 6:48
  • 1) Yes it works for libraries. 2) The asmx extension means it is a webservice. 3) Yes, no SharePoint installation needed. I would recommend getting familiar here: msdn.microsoft.com/en-us/library/… – Kit Menke Mar 8 '12 at 16:07
0

An easy way, but not always possible, is to use the webdav features of SP.

You can navigate with windows explorer using :

\\your.web.application\DavWWWRoot\sites\yoursite\yourlib
  • Yea, that’s actually the way which I use at the moment… But sadly the Metadata are missing at the directories. Could I add them afterwards? – user5167 Mar 7 '12 at 15:30
  • You can use an Http PUT query to drop files, then use the webservices to manipulate the data (also possible using webdav, but never tried) – Steve B Mar 7 '12 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy