none
Programmatically access remote sharepoint folder RRS feed

  • Question

  • hi all,

     I am a .net developer learning sharepoint. I have access to a sharepoint site which is hosted remotely. I need to check whether a list of files exist in this sharepoint folder.Each file exists in different folder path. I searched a lot in google and i found the code using Microsoft.sharepoint.dll but unfortunately, in my work area i couldn't get this dll files.

    So please help is there any easy way to do this without using Microsoft.sharepoint.dll ? I want to do this using C#/.net

    Thanks in advance

     

    Regards,

    Prem.

    Wednesday, January 28, 2009 2:55 PM

All replies

  • I posted some code which downloads files from Sharepoint via locally hosted .NET code.

     

    With a little adaption it could solve your problem. Post is at;

    http://www.the-north.com/sharepoint/post/Accessing-Sharepoint-Documents-from-Winforms-via-HTTPS.aspx


    Blog; http://www.the-north.com/sharepoint --- Posting is provided "AS IS" with no warranties, and confers no rights.
    Wednesday, January 28, 2009 3:01 PM
  • thank u Jamie McAllister. I will look into it and let u know if it helps me. Thanks for your reply
    Wednesday, January 28, 2009 3:02 PM
  • hi Jamie McAllister,

    The webclient class which you have used in your code doesn't have any method to check whether file exists or not. So how to proceed  with webclient?

    Wednesday, January 28, 2009 3:31 PM
  • I think you'd adapt it a little to create your own Exists property. If a WebRequest throws a WebException then the file doesn't exist. Not sure this is wonderfully efficient though, but frankly I can't think of a more efficient way unless your code is running in Sharepoint itself. I looked into Sharepoint Web Services for you, but they're not much better;

     private bool exists(string sPath)
    {
     System.Net.WebRequest oRequest;

    try{
     oRequest = System.Net.WebRequest.Create(sPath);

    return true;

    }

    catch (WebException)

    {

    return false;

    }

    }


    Blog; http://www.the-north.com/sharepoint --- Posting is provided "AS IS" with no warranties, and confers no rights.
    Wednesday, January 28, 2009 3:47 PM
  • hi Jamie McAllister,

    Thanks for your reply. Jamie is there any free access to sharepoint server in internet so that i can try executing the code which you gave or else i need to wait for another 12 hrs to check your code.

    Wednesday, January 28, 2009 4:00 PM
  • You could try that code with any file on the internet Sharepoint or not.

    Just remember that for your Sharepoint version you're probably going to have to create a Credentials object as detailed in the blog post you saw.


    Blog; http://www.the-north.com/sharepoint --- Posting is provided "AS IS" with no warranties, and confers no rights.
    Wednesday, January 28, 2009 4:13 PM
  • Hi,

    This code doesnt work. So is there any way to do without using microsoft.sharepoint.dll.
    Friday, April 10, 2009 6:55 PM
  • The original thread should still work for this. SharePoint DLL not needed.

    private bool exists(string sPath)
    {
     System.Net.WebRequest oRequest;
    try{
     oRequest = System.Net.WebRequest.Create(sPath);
    return true;
    }
    catch (WebException)
    {
    return false;
    }
    }


    w: http://www.the-north.com/sharepoint | t: @JMcAllisterCH | c: http://www.b-i.com

    Tuesday, October 2, 2012 4:21 PM