public byte[] GetDocument(Guid documentId)
		{
			SetConnection();
			var obj = new CF_Object(_conn, _container, _client, documentId.ToString());
			try
			{
				using (Stream stream = obj.Read())
				using (MemoryStream ms = new MemoryStream())
				{
					int count = 0;
					do
					{
						byte[] buf = new byte[1024];
						count = stream.Read(buf, 0, 1024);
						ms.Write(buf, 0, count);
					} while (stream.CanRead && count > 0);
					byte[] document = ms.ToArray();
					return document;
				}
			}
			catch (ObjectNotFoundException)
			{
				throw new ApplicationException(String.Format("Document not found [{0}]", documentId));
			}
		}
Beispiel #2
0
 public Stream ReadFile(string fileName)
 {
     if (!Authenticate()) throw new InvalidOperationException("Unable to authenticate");
     var fileObject = new CF_Object(_connection, _container.Name, fileName);
     return fileObject.Read();
 }