Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 0 down vote accepted

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.

share|improve this answer
    
Well, I will have a look tomorrow and gave you feedback, how it works. –  hofmeister 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? –  hofmeister Mar 8 '12 at 6:24
    
In addition, does the program run on a pc without SharePoint installation, if I use the SharePoint Services? –  hofmeister 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

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
share|improve this answer
    
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? –  hofmeister 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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.