public void CreateZonesFile(string inputFilename, string outputFilename, string guid, string userName, long userId, string completitionCode, DeviceType device, EngineVersion version) { FileStream inputStream = null; Cartridge cartridge; try { // Open Lua file inputStream = new FileStream(inputFilename, FileMode.Open); // Create input object for plain folders IInput input = new Folder(inputStream, inputFilename); // Check Lua file input.Check(); // Load Lua code and extract all required data cartridge = input.Load(); // Close input input = null; } finally { if (inputStream != null) { inputStream.Close(); inputStream = null; } } // Create selected engine IEngine engine = Compiler.CreateEngine(device); // Convert Lua code and insert special code for this player cartridge = engine.ConvertCartridge(cartridge); userName = engine.ConvertString(userName); // ---------- Compile Lua code into binary chunk ---------- // Compile Lua code cartridge.Chunk = LUA.Compile(cartridge.LuaCode, cartridge.LuaFileName); // ---------- Save cartridge as GWC file ---------- // Create object for output format (could be also WFC or any other IOutput) var outputFormat = new GWC(); // Write output file // Create output in correct format var ms = outputFormat.Create(cartridge, userName, userId, completitionCode); // Save output to file using (FileStream ofs = new FileStream(outputFilename, FileMode.Create)) { ms.CopyTo(ofs); // Close output ofs.Flush(); ofs.Close(); } }