You are here

About FileWrite

4 posts / 0 new
Last post
tony200910041
Offline
Last seen: 9 years 6 months ago
Joined: 2013-04-02 07:44
About FileWrite

Sorry, but I still want to ask what FileWrite actually does? When should I use it? Thanks.

Ken Herbert
Ken Herbert's picture
Offline
Last seen: 3 hours 25 min ago
DeveloperModerator
Joined: 2010-05-25 18:19
[FileWriteN] is used for when

[FileWriteN] is used for when you need to write something to the app's own files to properly implement portability. Generally speaking if you are performing a FileWrite on a file it should be somewhere within \Data (there are exceptions, but they are rare).

Some use cases for FileWrite:

  • Modifying paths stored in a config file that need to be handled as the drive/folder changes
  • Writing the language setting to a config file when implementing Platform-based language switching
  • Setting a default path on first run that requires a PAL environment variable
  • Forcing a setting to always be off for an app where it breaks portability (start with Windows, automatically associate filetypes, automatically update, etc.)
tony200910041
Offline
Last seen: 9 years 6 months ago
Joined: 2013-04-02 07:44
Thanks for answering. So is

Thanks for answering.
So is that mean the launcher will search for some words in the ini file's text and take action, for example, replacing the words?

Ken Herbert
Ken Herbert's picture
Offline
Last seen: 3 hours 25 min ago
DeveloperModerator
Joined: 2010-05-25 18:19
Mostly, yes

Depending on what you set the Type= value to depends on what it does exactly.

XML attribute and XML text are (obviously) specifically for updating attributes and text nodes in XML files using the XPath entry to determine where you are targeting, and replacing the attribute or node with the value you pass.

INI is specifically for files with a .ini style formatting (doesn't actually have to be called x.ini, though) where it has one or more [Sections] and within each section are lines of the format Key=Value. This will replace the value of the key with whatever you pass it.

ConfigWrite is like INI, but is less strict. It simply looks for any line beginning with what you pass it in the Entry=X parameter, and modifies the rest of the line to the value you pass it.

Replace seems to be the more commonly used type, and it simply looks for the existence of a string and replaces it with what you pass as a value.

Log in or register to post comments