Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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)

share|improve this question
    
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. –  Stuart Pegg Jun 30 '12 at 8:29
add comment

1 Answer

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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