문제

How do I copy document library documents to local drive programmatically in Sharepoint 2007?

도움이 되었습니까?

해결책

I'm not at my computer but something like this should do the trick.

using (SPSite site = new SPSite("http://sitecol"))
{
   SPWeb web = site.RootWeb;
   SPFolder docLib = web.GetFolder("DocLibName");

   foreach (SPFile f in docLib.Files)
   {
      // Use RWEP when accessing local file system
      SPSecurity.RunWithElevatedPrivileges(delegate(){
      {
         System.IO.File.WriteAllBytes(@"C:\Location\" + f.Name, f.OpenBinary());
      }
   }
}

Basically grab your site collection, then grab your spweb object, then grab your document library as a SPFolder. Then do a foreach loop through all the files in that folder, saving the byte array to your local filesystem.

Hope this helps!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top