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

Is it possible to save outside persistentDataPath?

Discussion in 'Scripting' started by NOT_A_ROBOT1101, Jul 13, 2020.

  1. NOT_A_ROBOT1101

    NOT_A_ROBOT1101

    Joined:
    Jun 18, 2020
    Posts:
    39
    I've seen games that save things outside of the persistentDataPath. Examples:

    Oxygen Not Included: saves on Documents folder
    PC Building Simulator: saves on "PC Building Simulator/saves" path

    How do I replicate this? I'm curious, because when I try to write something outside of persistentDataPath, it "doesn't have the permission" even if I run Unity Editor as admin.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,756
    Every OS target will be different. If you can open a text editor and write a file to the destination you are contemplating, then generally Unity should be able to do that, ASSUMING it is running as the same user and the same permission level as the text editor.
     
  3. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,907
    You should not. Always use the persistentDataPath. Writing in the installed application's directory is security risk and sometimes blocks proper uninstall. You don't want to cause garbage or security risk on the users' machines, right?
     
  4. NOT_A_ROBOT1101

    NOT_A_ROBOT1101

    Joined:
    Jun 18, 2020
    Posts:
    39
    Ok, I'm just wondering.
    Thanks for the reply!