file.Write
From GMod Wiki
Revision as of 17:37, 23 October 2011 by TheFreeman193 (Talk | contribs)
Function | |
Syntax |
file.Write( String filename, String contents ) Where is this used? |
Description: | |
Write to a specified file | |
Returns: | nil |
Part of Library: | File |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=File.Write]File.Write [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
You can only read/write text data. Binary data is not mutable inside Garry's Mod using the File library. |
Your filenames MUST end in .txt |
Examples
Description | This example writes "This is a test" to the my_mod/data.txt |
---|---|
Used on | |
Code | file.Write("my_mod/data.txt", "This is a test") |
Output | N/A |
Additional Notes
- Relative to garrysmod/data
- You cannot write to a file outside the data directory.
- You cannot write anything but *.txt files.
- Files are not opened in append mode. Files are emptied before they are written to. Use file.Append to append (add) to a file.
- The filename is decapitalized when the file is made, so "CAPSdontWORK.txt" will turn into "capsdontwork.txt" when saved
- You cannot write files with special characters such as the following, " : _ , this means you cannot save a filename as a SteamID
- As of the latest file.Write update, any filename containing a period will silently fail. This mean that you cannot use file names such as the following: "My_V1.1_Object.txt"