0

I have a few files in a document library which were never checked-in. I have that list of files available through the document library settings page or in c# using SPDocumentLibrary.CheckedOutFiles

Is there a way that I can download those files without taking their ownership via C#.

  • yes you can download the document library files via C# but what do you exactly mean by without taking their ownership? – Zakir HC May 20 '15 at 7:18
  • @ZakirHC please have a look at SPCheckedOutFile – Saksham May 20 '15 at 7:34
0

Well, if you have identified the files you need, why not just copying them as byte Arrays ? Just call the following method with the full file URL

public static byte[] GetBytesFromFile(string fullFilePath)
{
    FileStream fs = System.IO.File.OpenRead(fullFilePath);
    try
    {
        byte[] bytes = new byte[fs.Length];
        fs.Read(bytes, 0, Convert.ToInt32(fs.Length));
        fs.Close();
        return bytes;
    }
    finally
    {
        fs.Close();
    }
}
  • this won't work as 1. URI formats are not supported by File.OpenRead. 2. Even if it does, it is returning 404. – Saksham May 20 '15 at 8:46
  • I'm a bit surprised. It works very fine for me (O365 tenant) when I state the full file URL (https included). – Hammer May 20 '15 at 9:14

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.