ES2Web.AppendToFile

public void AppendToFile(string path)

Parameters

[table th=”0″]path,”The path of the file we want to append the data to, or create if it doesn’t exist.[/table]

Description

Appends our downloaded data to a given file. If the file doesn’t exist, it will be created.

Note that if the tag already exists in the file, it will not be overwritten. You will need to manually delete the existing tags if you wish to avoid this.

C#

A coroutine which Downloads all data stored in myFile.txt on the server and appends to a local file

public IEnumerator DownloadEntireFile()
{
    // As we don't specify a tag, it will download everything
    // within the file 'myFile.txt'.
      
    string myURL = "https://www.server.com/ES2.php?webfilename=myFile.txt";
    ES2Web web = new ES2Web(myURL);
      
    // Start downloading our data and wait for it to finish.
    yield return StartCoroutine(web.Download());
      
    if(web.isError)
    {
        // Enter your own code to handle errors here.
        // For a list of error codes, see www.moodkie.com/easysave/ES2Web.ErrorCodes.php
        Debug.LogError(web.errorCode + ":" + web.error);
    }
      
    // Now append our data to a local file so we can use ES2.Load to load it.
    web.AppendToFile("myFile.txt");
}

JS

A coroutine which Downloads all data stored in myFile.txt on the server and appends to a local file

function DownloadEntireFile()
{
    // As we don't specify a tag, it will download everything
    // within the file 'myFile.txt'.
      
    var myURL = "https://www.server.com/ES2.php?webfilename=myFile.txt";
    var web = new ES2Web(myURL);
      
    // Start downloading our data and wait for it to finish.
    yield StartCoroutine(web.Download());
      
    if(web.isError)
    {
        // Enter your own code to handle errors here.
        // For a list of error codes, see www.moodkie.com/easysave/ES2Web.ErrorCodes.php
        Debug.LogError(web.errorCode + ":" + web.error);
    }
      
    // Now append our data to a local file so we can use ES2.Load to load it.
    web.AppendToFile("myFile.txt");
}