Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Aug 29, 2019 at 04:40 PM by Firox_ for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Firox_ · Aug 29, 2019 at 01:00 PM · saveissuesave datadirectory

Where to put save file ?

I have a game that can be installed by a .exe. The save file is created in the same folder than the other files of the game. The issue is that, if the game is installed in a protected folder like Program Files, the save file can not be created or used because of restricted access. I think to create the save file in the AppData folder, but I don't know if it's a good way to solve my problem as this folder has not the purpose to contain save files. Is there a way to overcome the restriction of the Program Files folder ? If not, where would be the best place to put save files ?

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Magso · Aug 29, 2019 at 03:38 PM 0
Share

$$anonymous$$eep the save files in a folder with the game files and make it a hidden folder.

avatar image JedBeryll · Aug 29, 2019 at 04:07 PM 2
Share

"as this folder has not the purpose to contain save files" What do you mean by this? If you refer to Application.persistentDataPath, then it's a perfectly good place to keep the save files. Some people would argue that it takes too much space on the system drive, but that just depends on the number of files and their sizes.

avatar image Firox_ JedBeryll · Aug 29, 2019 at 04:39 PM 0
Share

For me the AppData folder should be used only for app config files. But I suppose it's fine to put save files in.

avatar image Bonfire-Boy · Aug 29, 2019 at 04:25 PM 0
Share

The great advantage of persistentDataPath is that it's always going to exist and be writable.

Given the OP's focus on "AppData" perhaps they're only deploying to Windows, in which case there'd be some sense in allowing people to save elsewhere (easier to navigate to, easier to back up, avoid filling up a small system drive, etc). But that's not going to be possible on many other platforms, and you need a default. The simplest default is going to be persistentDataPath for the reasons stated in first para, but some Windows users would probably thank you for defaulting to %USER%/Documents or something like that, ins$$anonymous$$d.

avatar image DCordoba · Aug 29, 2019 at 04:31 PM 0
Share

I support @jedBeryll oppinion, I use the persistent datapath on andoid (where application datapath cant be accessed normally) and app Datapath on portable editions, if you use a installer on windows Program Files, persistentDatapath is a good idea:

 //save two files, one after completely close the other, so if first fails, second with previous game can be recovered by the user, (or with the open file code)
 static string RecordsPath = Application.persistentDataPath + "/Records.jg";
 static string RecordsPath2 = Application.persistentDataPath + "/~Records.jg";

 //to debug, put editor saves inside proyect folder
 #if UNITY_EDITOR
     RecordsPath =  Application.dataPath + "/../Records.jg";
     RecordsPath2 = Application.dataPath + "/../~Records.jg";
 #endif

1 Reply

  • Sort: 
avatar image
0

Answer by Firox_ · Aug 29, 2019 at 04:40 PM

Thank you for your responses. I will use the AppData folder to put my save file.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

117 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity double save/back-up 1 Answer

Saving Melee Combat Template Pack (MY LAST PROBLEM) 1 Answer

Save Game Sceenes user quit aplication, Can I save the scene as a whole while leaving the game? 0 Answers

Save system for a Motherload-like game. 1 Answer

Building a survival game with dedicated servers? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges