Up vote 1 down vote favorite share g+ share fb share tw.
I'm trying to download a txt file from a subfolder within a folder in a document library. I'm using camlQuery to achieve this. Unfortunately, I get no content of the txt file.
It has 0 byte. Public void SaveFolderFiles(string fileName, string libraryName, ClientOM. ClientContext clientContext) { ClientOM.
List sharedDocumentsList = clientContext.Web.Lists. GetByTitle(libraryName); ClientOM. CamlQuery camlQuery = new ClientOM.CamlQuery(); camlQuery.
FolderServerRelativeUrl = "/Site/Folder/Folder2010/"; camlQuery. ViewXml = @" " + fileName + @" 1 "; ClientOM. ListItemCollection listItems = sharedDocumentsList.
GetItems(camlQuery); clientContext. Load(sharedDocumentsList); clientContext. Load(listItems); clientContext.ExecuteQuery(); if (listItems.
Count == 1) { ClientOM. ListItem item = listItems0; Console. WriteLine("FileLeafRef: {0}", item"FileLeafRef"); Console.
WriteLine("FileDirRef: {0}", item"FileDirRef"); Console. WriteLine("FileRef: {0}", item"FileRef"); Console. WriteLine("File Type: {0}", item"File_x0020_Type"); ClientOM.
FileInformation fileInformation = ClientOM.File. OpenBinaryDirect(clientContext, (string)item"FileRef"); using (MemoryStream memoryStream = new MemoryStream()) { fileInformation.Stream. CopyTo(memoryStream); using (FileStream fileStream = File.
Create(@"D:\" + item"FileLeafRef".ToString())) { memoryStream. CopyTo(fileStream); } memoryStream.Flush(); } } else { Console. WriteLine("Document not found.
"); } } Maybe someone has an idea? Regards c# sharepoint2010 caml sharepoint-clientobject client-object-model link|improve this question asked Apr 5 at 7:42float758 82% accept rate.
Try this: using FileInformation and get the MemeryStream string fileurl = (string)liitem"FileRef"; FileInformation ffl = Microsoft.SharePoint.Client.File. OpenBinaryDirect(clientContext, fileurl); byte bytesarr = ReadFully(ffl. Stream); MemoryStream mnm = new MemoryStream(bytesarr); ReadFully function Which convert Stream to Bytes array public byte ReadFully(Stream input) { byte buffer = new byte16 * 1024; using (MemoryStream ms = new MemoryStream()) { int read; while ((read = input.
Read(buffer, 0, buffer. Length)) > 0) { ms. Write(buffer, 0, read); } return ms.ToArray(); } }.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.