示例#1
0
        public void WriteEncoded(EncodedFile file)
        {
            var entireFile = new HeaderParser().WriteHeader(file.Header, file.Content);

            var path = file.Path;
            var index = path.LastIndexOf('.');
            if (index > -1)
            {
                path = path.Remove(index, path.Length - index);                
            }
            path += ".rsb";

            File.WriteAllBytes(path, entireFile);
        }
示例#2
0
        public EncodedFile ReadEncoded(string path)
        {
            var fileInfo = new FileInfo(path);

            if (!fileInfo.Exists)
            {
                throw new FileNotFoundException(path);
            }

            var bytes  = File.ReadAllBytes(path);
            var stream = new MemoryStream(bytes);

            var header = new HeaderParser()
                         .ReadHeader(stream, out byte[] content);

            return(new EncodedFile(header, content));
        }