Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Specify another path for System.IO.File

Discussion in 'Scripting' started by bplc, Sep 17, 2022.

  1. bplc

    bplc

    Joined:
    Mar 10, 2022
    Posts:
    104
    Hello,

    I just created a script that allows me to create a file with
    System.IO.File


    The file is created at the source of my games folder.

    What I would like to know is how to specify a specific path.
    For save this file in another folder.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,513
  3. bplc

    bplc

    Joined:
    Mar 10, 2022
    Posts:
    104
    thank's
     
  4. bplc

    bplc

    Joined:
    Mar 10, 2022
    Posts:
    104
    Found
    System.IO.File.WriteAllText("myFolder\\myFile, "myText");

    System.IO.File.WriteAllText("myFolder/myFile, "myText");
     
    Last edited: Sep 17, 2022
  5. pantang

    pantang

    Joined:
    Sep 1, 2016
    Posts:
    219
    application.datapath + "/myfolder/myfile.meh"

    will write to the games folder, you will need to make the directory first, application.streamingassets is another useful one as well.