Dwonloading file from Sharepoint

Status
Not open for further replies.

Fulgan

Ars Tribunus Angusticlavius
7,534
Subscriptor
Hello folks,

I find myself stuck in an uncomfortable position again: I'm asked to estimate the time necessary to develop a program that will:

- Connect to a remote sharepoint server over Internet
- Go through a list of "directories"
- Download all PDF files that are in these directories
- Delete the downloaded files

(The result will be stored into an internal database which is already in production)

My problem:

- I don't know what version of Sharepoint is going to be used.
- I know next to nothing about Sharepoint.
- I don't have a test system available.
- The final customer is one of these... less than perfect customers that combine unrealistic expectations, high self-esteem, poor technical knowledge and, above all, bad faith by the truckload (i.e. I have to make sure all the "i"s are dotted and all the "t"s are crossed).

Would anyone please tell me, to the best of your knowledge, a) if it's possible b) if implementation depends on the version of sharepoint c) if it's trivial, medium or hard and d) if there is a good resource about this (I'm downloading the sharepoint 2010 SDK right now).

Thanks
 

wallinbl

Ars Legatus Legionis
14,335
Subscriptor
Nearly every list in SharePoint can be turned into a webservice (and has an actual .asmx you can hit). If a particular list is at http://SharePointServer/HRSite/Tasks/, then there should be a web service at http://SharePointServer/HRSite/_vti_bin/lists.asmx or something like that. If you want a list of Webs, the URL will be /_vti_bin/webs.asmx and so on. The Microsoft.SharePoint.dll has a number of object classes that can consume these web services. You can grab this dll from the server (in SharePoint world, you're supposed to have SharePoint installed on the same machine that Visual Studio is installed on, but this is nothing but a pain in the ass).

Your code would look something like this for a list:
Code:
spList.Lists lists = new spList.Lists();
lists.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; // if you're on the same domain and have access to the list
lists.Url = "http://SharePointServer/HRSite/_vti_bin/lists.asmx"; 

System.Xml.XmlNode tasks = lists.GetList("Tasks");
That would get you some XML representing all the items in a list called Tasks. It's been a while since I messed with this stuff, so that may be slightly off. You should be able to use that same general concept for files and other items in SharePoint.

You could probably hit the web services straight up without the dll if you really want do.
 

Fulgan

Ars Tribunus Angusticlavius
7,534
Subscriptor
Akula":zxkg5uqo said:
You could also just use Webdav for an Explorer-like interface (\\sharepoint.domain.com\Site\Doc Lib\).

After trying to deal with the heap of crap that is sharepoint: I finally went down that way: replaced 150+ lines of ugly code (thanks to sharepoint "concept" of working only with XML snippets) replaced by 30 lines of simple code. It's even faster.

Thank you, all.
 
Status
Not open for further replies.