Search Unity

error CS0117: `System.IO.File' does not contain a definition for 'CreateText'

Discussion in 'Scripting' started by FingerPunch, Jan 25, 2015.

  1. FingerPunch

    FingerPunch

    Joined:
    Feb 17, 2013
    Posts:
    2
    Hi everyone.

    I'm having issues with a Web Player version of our game. All other builds work fine, but the web player keeps raising issues with the above information.

    I'm not a coder, and the coder who made this is no longer with us, so have no idea how to correct this problem. I've checked other forum posts with similar issues and have tried changing the .Net version, also the switching platform button etc. but this error won't go away.

    As far as i am aware, the code creates a border shape from numerous images using text files which donate the shape and size of every new level border. Specific numbers, and letters, refer to different aspects of the game board and the border that should surround them. Outside of this, i'm at a loss and would greatly appreciate any help that anyone can offer.

    Thanks,

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System;
    4. using System.IO;
    5.  
    6. public class Mod_levels : MonoBehaviour
    7. {
    8.     void Awake()
    9.     {
    10.         for(int i = 0; i<=100;i++)
    11.         {
    12.             if(i % 10 != 5 && i % 10 != 6)
    13.             {
    14.                 string j = i.ToString();
    15.                 while (j.Length < 3)
    16.                     j = "0" + j;
    17.                 TextAsset t = Resources.Load("Levels/lvl_" + j + "_plan") as TextAsset;
    18.                 print (j);
    19.                 string[] result = t.text.Split (new string[] {"\n", "\r\n"}, System.StringSplitOptions.RemoveEmptyEntries);
    20.  
    21.                 string[] newFile = new string[result.Length+2];
    22.                 if(i > 4)
    23.                     newFile[0] = "7777777777";
    24.                 else
    25.                     newFile[0] = "77777777";
    26.          
    27.                 for(int x =0; x < result.Length; x++)
    28.                     newFile[x+1] = "7" + result[x] + "7";
    29.  
    30.                 if(i > 4)
    31.                     newFile[newFile.Length-1] = "7777777777";
    32.                 else
    33.                     newFile[newFile.Length-1] = "77777777";
    34.  
    35.                 var sr = File.CreateText("lvl_"+j+"_plan.txt");
    36.                 for(int y = 0; y < newFile.Length; y++)
    37.                 {
    38.                     sr.WriteLine (newFile[y]);
    39.                 }
    40.                 sr.Close();
    41.             }
    42.         }
    43.     }
    44. }
     
  2. Deleted User

    Deleted User

    Guest

    For secuity resons the webplayer doesnt allow local file access
     
  3. FingerPunch

    FingerPunch

    Joined:
    Feb 17, 2013
    Posts:
    2
    Thanks element_wsc.