Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
|
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2007, 10:02 PM
Registered User
 
Join Date: Nov 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to pinkflakes
Default help...copy files from sharepoint to local folder

please help me....

I want to copy all files from sharepoint document library to my local folder

here is mycode: I got an error message (value does not fall within the expecte range)

please help....

I don't know what to do next...





----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    class Program: MyClass
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("please wait");
            Console.ReadLine();
            try
            {
              MyClass z = new MyClass();
              z.DownloadDocumentsFromFolder(@"http://personal/administrator/b");
              z.DownloadFileFromSharePointFolder(@"C:\mn");
           }
            catch (Exception Ex)
            {
                Console.Error.WriteLine(Ex.Message);
                Console.Read();
            }
        }
    }
}







-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------





    class MyClass
    {
        byte[] fileInfo;
        string fileName;

        public string DownloadDocumentsFromFolder(string spSiteUrl)
        {

            SPSite siteurl = new SPSite(@"http://personal/administrator/b/Forms/AllItems.aspx?RootFolder=%2fpersonal%");
            SPWeb web = siteurl.OpenWeb();
            SPFolder SelectedFolder = web.GetFolder((@"http://personal/administrator/b/") + "ann");

            //if (SelectedFolder.SubFolders.Count > 0)
            //{
                foreach (SPFolder folderCollection in SelectedFolder.SubFolders)
                {
                    if (folderCollection.Name == "ann")
                    {
                        SPFolder folderToDownload = web.GetFolder(folderCollection.Url);
                        for (int i = 0; i < folderToDownload.Files.Count; i++)
                        {
                            if (fileName == folderToDownload.Files.Folder.Name)
                            {
                                fileInfo = new byte[100];
                                fileInfo = DownloadFileFromSharePointFolder(folderToDownload. Files.Folder.Url);
                            }
                        }
                    }
                }
           // }
            return Convert.ToString(fileInfo);
        }
        public byte[] DownloadFileFromSharePointFolder(string spFileURL)
        {

            SPSite site = new SPSite(@"http://personal/administrator/b/Forms/AllItems.aspx?RootFolder=%2fpersonal%");
            SPWeb web = site.OpenWeb();
            SPFile sourceFile = web.GetFile(@"C:\mn"); // the problem lies here, It stopped here and displayed the error

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

            Console.WriteLine(fileData);
            return fileData;

            Console.Read();



        }
    }
}









Similar Threads
Thread Thread Starter Forum Replies Last Post
Where is the "Local Drafts Folder" btracy BOOK: Beginning SharePoint 2007: Building Team Solutions with MOSS 2007 ISBN: 978-0-470-12449-9 2 June 28th, 2010 02:20 PM
local folder location euschenk Classic ASP Basics 3 March 5th, 2008 04:46 PM
Copy Files and Folders on Local Network rupakroy5 VB.NET 2002/2003 Basics 1 May 22nd, 2006 10:09 AM
Copy Local, Reference property ps2goat .NET Framework 1.x 1 October 24th, 2005 03:13 PM
Getting the a local copy of the Server DB Sappu SQL Server ASP 2 March 21st, 2005 12:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.