Hello,
I'm currently working on the integration of BaseX in part of our .Net based software. One part of the functionality will be to store and retrieve binary files. I haven't been able to retrieve the raw files from the server yet using C#. I based my solution on the example of the C# client in the source code repository of BaseX. With my current solution I receive only the first few (3 to 7) bytes of the file (at least I think they are...).
The code I have at the moment is:
/// <summary> /// Retrieves a RAW document from the database. The database must be opened before executing this command. /// </summary> /// <param name="path">The path to the binary data to be retrieved</param> /// <returns>A byte array with the binary data</returns> public byte[] Retrieve(string path) { //stream.WriteByte((byte)BaseXCommand.QUERY); Send("RETRIEVE " + path); //Send(path);
using (MemoryStream ms = new MemoryStream()) { Receive(ms); info = Receive(); if (!Ok()) { throw new IOException(info); } return ms.ToArray(); } }
Can anybody please tell me what the problem with this solution can be or give me a hint for a correct way to retrieve the raw bytes? I know I can use the files on disk directly, but would rather not go that way.
Thanks in advance for your reaction!
Kind regards,
Björn Boxstart