Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Stream stream = null;
- if (loadFromResources == true)
- {
- TextAsset textAsset = Resources.Load(fullPath) as TextAsset;
- Debug.Log(textAsset);
- stream = new MemoryStream(textAsset.bytes);
- }
- else
- {
- FileInfo fi1 = new FileInfo(fullPath);
- if (fi1.Extension.Equals(".gz"))
- {
- stream = new MemoryStream();
- byte[] buffer = new byte[4096];
- using (Stream inGzipStream = new GZipStream(File.Open(fullPath,FileMode.Open), CompressionMode.Decompress))
- {
- int bytesRead;
- while ((bytesRead = inGzipStream.Read(buffer, 0, buffer.Length)) > 0)
- {
- stream.Write(buffer, 0, bytesRead);
- }
- }
- }
- else
- stream = File.Open(fullPath, FileMode.Open);
- }
- using (BinaryReader reader = new BinaryReader(stream))
- {
- //header headerKey substruct:
- headerKey.sizeof_hdr = reader.ReadInt32(); //ERROR
- }
Add Comment
Please, Sign In to add comment