What is the best way to output data from Unity to a text file?

What is the best way to output data from Unity to a text file?

I have an example project create by another research group using c# for file IO that is called from other javascript applications.

Specifically, how do you call file I/O from c#

using UnityEngine;
using System.Collections;
using System.IO;
using System;

public class logger : MonoBehaviour {

    private StreamWriter sw0;//player stats
    private StreamWriter sw1;//player movement data

    private DateTime currTime;

    private static logger s_Instance = null;
    public static logger instance {
        get {
            if (s_Instance == null) {
                s_Instance =  FindObjectOfType(typeof (logger)) as logger;
            return s_Instance;

    void Start () {

        Debug.Log("File I-O");

        currTime = DateTime.Now;
        string append = currTime.ToString("yyyy-MM-dd_HHmmss")+".txt";

        sw0 = new StreamWriter("PlayerStats_"+append);
        sw1 = new StreamWriter("PlayerMovement_"+append)

    s_Instance = null;

Later in javascript file attached to the game object I have:

    //Logger = GetComponent("Logger");  
    //var Logger : Logger  = GetComponent (Logger);


But Unity cannot find the reference to Logger.

I cannot find any reliable method to get file I/O from Unity and want to know the expected way to generate .txt files from data created during runtime. Is this a Unity Pro only feature?

you can use `System.IO.File.WriteAllText("~/myfile","mytext");`

this is not available in the webplayer for security reasons.