Get File List in SharePointer using C#
Hi
I am new to SharePoint and I want to get MsWord file list which I have stored in SharePointer Server.
Could someone give me a small sample in C# for this?
Hi
I am new to SharePoint and I want to get MsWord file list which I have stored in SharePointer Server.
Could someone give me a small sample in C# for this?
This is really the wrong forum sharepoint but perhaps I can help as I program Sharepoint daily.
Unfortunately though I'm not entirely sure what you're asking to do. Is it a case that you've stored a word document in a sharepoint document library and want to programatically get that document? Do you have sharepoint deployed or just WSS? Also what versions are you running?
Colin Brown
MSN MVP
Hi Colin
Thanks for the reply. I am using share point portal server and its version is 2003.
Different users upload Ms word files to my shartepoint library and now I want to get the file list programatically. I have good experience in C#, but very new to Sharepoint. So Can you give me quick start how to do this task?
jude
OK, this is actually fairly easy to do.
First thing you need to do is to add a reference the Sharepoint.dll in your project.
Then in your code add :-
using Microsoft.Sharepoint;
Next you need a pointer to your site then to load the web that hosts the library. Once that's done you can get a reference to the library and the objects in it.
SPSite mysite = new SPSite("http://localhost") // replace localhost with the URL of your site
SPWeb myweb = mysite.OpenWeb();
SPFolder mylibrary = myweb.Folders["Name of library"];
SPFileCollection files = mylibrary.Files;
"files" now contains a collection of files from your document library. You can iterate through them, copy them, basically do what you want with them.
Colin Brown
MSN MVP