Garry's Mod Wiki

Garry's Mod Wiki

  boolean file.Write( string fileName, string content )

Description

Writes the given string to a file. Erases all previous data in the file. To add data without deleting previous data, use file.Append.

Arguments

1 string fileName
The name of the file being written into. The path is relative to the data/ folder.

This argument will be forced lowercase.

The filename must end with one of the following:

  • .txt
  • .dat
  • .json
  • .xml
  • .csv
  • .dem
  • .vcd
  • .gma
  • .mdl
  • .phy
  • .vvd
  • .vtx
  • .ani
  • .vtf
  • .vmt
  • .png
  • .jpg
  • .jpeg
  • .mp3
  • .wav
  • .ogg

Restricted symbols are: ":, and multiple consecutive spaces

2 string content
The content that will be written into the file.

Returns

1 boolean
If the operation was successful
This was recently added in version (2025.01.10). It might only be available on the Dev Branch right now.

Example

Writes to data/helloworld.txt.

file.Write( "helloworld.txt", "This is the content!" )

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...