3

First of all let me start by saying that I'm not a professional SharePoint 2010 developer. I know some basics and read about how SharePoint is constructed and stuff, played with it a little, but it was only out of curiosity not for work.

And now I have a problem. Our SP developer can't be reached for about 2 weeks and I was given the urgent task of changind permissions on some documents in a document center. I have the list of all the document IDs that I must change. So, I was thinking to write a console app, get the documents one by one and change the permissions.

But I have no ideea how to get the documents based on the Document ID.

Can you point me to some example or resource to get files based on their Document ID? So far I wasn't able to find anything usefull but there is a great change that I'm not looking it up correctly (as I said, I'm not very familiar with SharePoint)

  • If you want to skip a step, you may want to look into PowerShell. That way you could make the script without faffing around with installing SharePoint on your dev machine to get the DLLs. – Stu Pegg Jun 30 '12 at 8:29
1

try this if it helps

 public static SPFile FindFileWithDocumentID(string docID)
 {
      SPFile file = null;
      string url = string.Empty;


      using (SPSite site = new SPSite("http://basesmc2008"))
      {
        string[] urls = Microsoft.Office.DocumentManagement.DocIdLookup.DoSearch(site, docID);
        if (urls != null && urls.Length > 0)
          url = urls[0];

        using (SPWeb web = site.OpenWeb())
        {
          file = web.GetFile(url);

        }

      }

      return file;

}

OR you can also look at this post

Similar Question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.