fNbt.NbtFile.SaveToFile C# (CSharp) Method

SaveToFile() public method

Saves this NBT file to a stream. Nothing is written to stream if RootTag is null.
is null. If AutoDetect was given as the mode. If an unrecognized/unsupported value was given for . If given stream does not support writing. If an I/O error occurred while creating the file. Specified file is read-only, or a permission issue occurred. If one of the NbtCompound tags contained unnamed tags; /// or if an NbtList tag had Unknown list type and no elements.
public SaveToFile ( [ fileName, NbtCompression compression ) : long
fileName [ File to write data to. May not be null.
compression NbtCompression Compression mode to use for saving. May not be AutoDetect.
return long
        public long SaveToFile([NotNull] string fileName, NbtCompression compression)
        {
            if (fileName == null) throw new ArgumentNullException("fileName");

            using (
                var saveFile = new FileStream(fileName,
                                              FileMode.Create,
                                              FileAccess.Write,
                                              FileShare.None,
                                              FileStreamBufferSize,
                                              FileOptions.SequentialScan)) {
                return SaveToStream(saveFile, compression);
            }
        }

Usage Example

Ejemplo n.º 1
0
		public static void SaveLevel(LevelInfo level)
		{
			if (!Directory.Exists(_basePath))
				Directory.CreateDirectory(_basePath);

			NbtFile file = new NbtFile();
			NbtTag dataTag = file.RootTag["Data"] = new NbtCompound("Data");
			level.SaveToNbt(dataTag);
			file.SaveToFile(Path.Combine(_basePath, "level.dat"), NbtCompression.ZLib);
		}
All Usage Examples Of fNbt.NbtFile::SaveToFile