FileStore.FileStore.ReadFile C# (CSharp) Method

ReadFile() public method

Get the contents of the given file.
public ReadFile ( StoreFile file ) : byte[]
file StoreFile The file from which to get the data.
return byte[]
        public byte[] ReadFile(StoreFile file)
        {
            if(file == null) {
                throw new ArgumentNullException("file");
            }

            // check if there is anything to read
            if(file.Data == null) {
                return null;
            }

            byte[] data = file.Data;

            if((file.StoreMode & StoreMode.Encrypted) == StoreMode.Encrypted) {
                data = DecryptData(data);
            }

            if((file.StoreMode & StoreMode.Compressed) == StoreMode.Compressed) {
                data = DecompressData(data);
            }

            if(data.Length > file.RealSize) {
                byte[] buffer = new byte[file.RealSize];
                Buffer.BlockCopy(data, 0, buffer, 0, (int)file.RealSize);

                return buffer;
            }

            return data;
        }

Same methods

FileStore::ReadFile ( string path ) : byte[]