コード例 #1
0
 /// <summary>
 /// Writes the zone to a file.
 /// </summary>
 /// <param name="czhFile">File system path to the ".czh_pc" zone file.</param>
 public void WriteHeaderFile(string czhFile)
 {
     FileStream stream = null;
     SRBinaryWriter binaryWriter = null;
     try
     {
         if (vFileHeader == null || worldZoneHeader == null)
             throw new SRZoneFileException("No zone header to write.");
         stream = File.Open(czhFile, FileMode.Create);
         binaryWriter = new SRBinaryWriter(stream);
         vFileHeader.Write(binaryWriter);
         worldZoneHeader.Write(binaryWriter);
     }
     catch (Exception e)
     {
         // Add context information for the error message
         e.Data["Action"] = "writing Zone Header file";
         throw;
     }
     finally
     {
         if (binaryWriter != null)
             binaryWriter.Close();
     }
 }
コード例 #2
0
 /// <summary>
 /// Writes the zone to a file.
 /// </summary>
 /// <param name="cznFile">File system path to the ".czn_pc" zone file.</param>
 public void WriteDataFile(string cznFile)
 {
     FileStream stream = null;
     SRBinaryWriter binaryWriter = null;
     try
     {
         if (sectionList == null)
             throw new SRZoneFileException("No zone data to write.");
         stream = File.Open(cznFile, FileMode.Create);
         binaryWriter = new SRBinaryWriter(stream);
         int index = 0;
         foreach (SRZoneSection section in sectionList)
             section.Write(binaryWriter, index++);
     }
     catch (Exception e)
     {
         // Add context information for the error message
         e.Data["Action"] = "writing Zone Data file";
         throw;
     }
     finally
     {
         if (binaryWriter != null)
             binaryWriter.Close();
     }
 }