Welcome to Office & SharePoint Pro Sign in | Join | Help

SUBSCRIBE to Windows IT Pro Magazine & SAVE 30%      FREE Email Newsletters Vista UPDATE, Windows IT Pro UPDATE & More

Re: please help..how to copy all files from sharepoint to local folder

  •  01-03-2008, 10:00 PM

    Re: please help..how to copy all files from sharepoint to local folder

    Hi dude if u wanna to copy all files from your sharepoint you should save the files by the different formats like below here my code save the htm file from sharepoint to our local disk. this code snippet is working in vs .net 2005 c#.

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

     

    using System;

    using System.Data;

    using System.IO;

    using System.Configuration;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Web.UI.HtmlControls;

    using Microsoft.SharePoint;

    using Microsoft.SharePoint.WebControls;

    public partial class _Default : System.Web.UI.Page

    {

    protected void Page_Load(object sender, EventArgs e)

    {

    SPSite mysite = new SPSite("http://origin23:334/");

    SPWeb myweb = mysite.OpenWeb();

    myweb.AllowUnsafeUpdates = true;

    SPFolder fold = myweb.GetFolder("test/testfolder");

    SPFileCollection files = fold.Files;foreach (SPFile x in files)

    {

    Response.Write(x.Name.ToString());

    if (x.Name.ToString() == "How to query all today's events in a sharepoint calendar - MSDN Forums.htm")

    {

    FileStream fs = new FileStream(@"D:/Accounter.htm", FileMode.Create);

    BinaryWriter binaryWriter = new BinaryWriter(fs);

    byte[] fileData = (byte[])x.OpenBinary();

    binaryWriter.Write(fileData);

    binaryWriter.Close();

    }

    }

    }

    }

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

     

    Filed under:
View Complete Thread
SPONSORED LINKS FEATURED LINKS

SharePoint Security SimplifiedHaving trouble with Permissions in your SharePoint environment? Check out USPM v2007® Order Your Fundamentals CD Today!Get up to speed quickly and learn how to uncover rich information management and deployment capabilities with this free SharePoint CD. Simplify Content Migration for SharePointEase the job of SharePoint migration and ongoing site maintenance. Michael Noel outlines your migration options in this white paper. Download today! Prepare Yourself for Exchange CatastropheRead this white paper to learn how you can keep Exchange server healthy, as well as predict and respond to server failure. Featured eBook - Fundamentals of Fax Server TechnologyTake advantage of the benefits of fax servers and find out how you can implement a solution that is easy to support, secure, and integrate. Dramatically Accelerate Microsoft SharePointDeliver unimpeded access to SharePoint - Learn how to fix more than just the symptoms of slow application delivery and poor performance. Protect Your Company’s Digital AssetsDo you know the risks of sending important files over email or FTP? Read this white paper to learn what you can do to safeguard your company’s data. Boost Customer Confidence and SatisfactionRead this eBook to learn how fax servers can ease communication with less computer-savvy customers while reducing your security, compliance, and support woes. Implement a Successful Archiving SolutionView this web seminar to learn the best practices for creating an email archive that is secure, compliant, and searchable.