public void WritePackToDirectory(string directory) { for (int i = 0; i < files; i++) { using (FileStream s = File.Open(filename, FileMode.Open, FileAccess.Read)) using (BinaryReader reader = new BEBinaryReader(s)) using (FileStream outfile = File.Open(directory + Path.DirectorySeparatorChar + filenames[i], FileMode.Create, FileAccess.Write)) { s.Seek(fileData[i].offset, SeekOrigin.Begin); byte[] file = reader.ReadBytes(fileData[i].size); outfile.Write(file, 0, file.Length); } } }
public void Extract(string directory) { using (FileStream s = File.Open(FileName, FileMode.Open, FileAccess.Read)) using (BinaryReader reader = new BEBinaryReader(s)) foreach (KeyValuePair <String, FileData> entry in Files) { using (FileStream outfile = File.Open(directory + Path.DirectorySeparatorChar + entry.Key, FileMode.Create, FileAccess.Write)) { s.Seek(entry.Value.offset, SeekOrigin.Begin); byte[] file = reader.ReadBytes(entry.Value.size); outfile.Write(file, 0, file.Length); } } }
public byte[] GetFile(string fileName) { if (!Files.Keys.Contains(fileName)) { return(null); } FileData fData = Files[fileName]; using (FileStream s = File.Open(FileName, FileMode.Open, FileAccess.Read)) using (BinaryReader reader = new BEBinaryReader(s)) { s.Seek(fData.offset, SeekOrigin.Begin); byte[] file = reader.ReadBytes(fData.size); return(file); } }
public void Extract(string fileName, string directory) { if (!Files.Keys.Contains(fileName)) { return; } FileData fData = Files[fileName]; using (FileStream s = File.Open(FileName, FileMode.Open, FileAccess.Read)) using (BinaryReader reader = new BEBinaryReader(s)) using (FileStream outfile = File.Open(directory + Path.DirectorySeparatorChar + fileName, FileMode.Create, FileAccess.Write)) { s.Seek(fData.offset, SeekOrigin.Begin); byte[] file = reader.ReadBytes(fData.size); outfile.Write(file, 0, file.Length); } }