Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
.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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 3rd, 2007, 10:02 PM
Registered User
 
Join Date: Nov 2007
Location: , , .
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();



        }
    }
}




Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:20 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.