public static void AddFiles(IPackage package, List <string> sourceFilePaths) { List <TGIN> addedResourceKeys = new List <TGIN>(); for (int sourceFilePathIndex = 0; sourceFilePathIndex < sourceFilePaths.Count; sourceFilePathIndex++) { string sourceInfoFilePath = sourceFilePaths[sourceFilePathIndex] + "." + SourceInfoFileExtension; TGIN targetResourceKeyTGIN = Path.GetFileName(sourceFilePaths[sourceFilePathIndex]); if (File.Exists(sourceInfoFilePath)) { try { SourceInfo sourceInfo = (SourceInfo)Tools.ReadXML <SourceInfo>(sourceInfoFilePath); targetResourceKeyTGIN = sourceInfo.ToTGIN(); } catch (Exception e) { Console.Error.Write("Failed to read source info file.\n" + sourceInfoFilePath + "\n" + e.ToString()); } } AResourceKey targetResourceKey = targetResourceKeyTGIN; MemoryStream sourceStream = new MemoryStream(); BinaryWriter sourceStreamWriter = new BinaryWriter(sourceStream); using (BinaryReader sourceFileReader = new BinaryReader(new FileStream(sourceFilePaths[sourceFilePathIndex], FileMode.Open, FileAccess.Read))) { sourceStreamWriter.Write(sourceFileReader.ReadBytes((int)sourceFileReader.BaseStream.Length)); sourceStreamWriter.Flush(); } IResourceIndexEntry targetPreviousEntry = package.Find(targetResourceKey.Equals); while (targetPreviousEntry != null) { package.DeleteResource(targetPreviousEntry); targetPreviousEntry = package.Find(targetResourceKey.Equals); } IResourceIndexEntry targetEntry = package.AddResource(targetResourceKey, sourceStream, false); if (targetEntry == null) { continue; } targetEntry.Compressed = 23106; addedResourceKeys.Add(targetResourceKeyTGIN); } GenerateNameMap(package, addedResourceKeys, null); }