Why should I store my data in ApplicationData folder and not in the installation dir?

I guess the subject says it all.
I’m a big fan of portable apps. What’s so bad about the installation folder for data storage? (you move the folder, you move the application, you move the data)
Thanks

On Mac, writing in the Applications folder is not permitted without higher permissions, so your program will fail.

Under Windows, Microsoft does not recommend writing to files in the Program Files directory, for the same reason.

If your program is all on an USB stick, that is OK since the folder is not reserved.

[quote=271575:@Roman Varas]I guess the subject says it all.
I’m a big fan of portable apps. What’s so bad about the installation folder for data storage? (you move the folder, you move the application, you move the data)
Thanks[/quote]

I’m very much a fan of the portable idea. I hate these OS conventions as to where you put your stuff, with the OS creating more and more restrictions with each version. And things get buried down in a semi-incomprehensible directory structure littered with god-knows-what and shortcuts you are not allowed to use ( Windows anyway ). It is the same with installers that plonk crud all over your machine and registry, in the latter case putting in entries that are for-all-intents-and-purposes hidden to keep track of your licensing and preventing you from re-installing if your 30 day trial is over. This crud is often not removed by the uninstaller ( for obvious reasons ). Stuff that for a bad job.

Besides, the place where I for example store many downloads is bigger than the free space on the system drive - so forget using the ruddy “Downloads” folder buried under my user folder. Or using “My Music” as an invitation for some ghastly software to try to “organise” it, so kindly, for me.

Thankfully I write stuff for my own use mostly, so I can do what I will, which is normally to store data with the program, in its own directory, where I can find it without having to open up vast number of Explorer windows, or even revert to the OS’s search function ( which can be a bizarre experience on Win).

As an Apple guy, I still follow Windows conventions when making a Windows app.

Even if you don’t like it as a personal preference, if you’re going to make an app for a platform, you should, by and large, follow that platform’s conventions. Just my opinion.

I do try to follow conventions as well. Actually, I was asking about the rationale of the application data folder vs installed folder. It’s still not clear to me. Is Michel’s answer the only reason? (write permission in applications folder needs higher permission)

[quote=271575:@Roman Varas]I guess the subject says it all.
I’m a big fan of portable apps. What’s so bad about the installation folder for data storage? (you move the folder, you move the application, you move the data)
Thanks[/quote]
Some people will not have privileges to save data next to the app so saving your data may fail
That would be VERY unusual for the ApplicationData directory so its almost certain to not fail (although there are still reasons it might)

I work on an app that has been around since long before these recommendations were in place. Many of our users place the app into a separate folder so that all it’s support documents and data can be along side the app and portable as you say.

When the app first starts up I check to see where it’s actually located. If it’s parent folder is the Applications folder then I look for or create the database and support folders in it’s Application Support folder. If it’s not in the Applications folder then I look for them inside the parent folder of the App.

That way people who want to do things the new way are supported and people who want it all in the same place are also supported. I’ve also added a menu item for “reveal database in finder” that opens the folder that contains all the support data in the finder to make it easier to get ahold of it if they want to move it around and it’s in the application support folder.

Yes.

.[quote=271581:@Peter Job]I’m very much a fan of the portable idea. I hate these OS conventions as to where you put your stuff, with the OS creating more and more restrictions with each version. [/quote]

Before you pull the faggot and torch against Apple and MS for trying to create order in chaos, with minimal rules of where things are to go in their system.

The rule applies if you put your program in /Applications on Mac or in \Program Files in Windows. In other words, their folder, their rules. But if you are to create a folder somewhere else, for instance in myFolder within Documents or pretty much anywhere the user has access, you can put in there whatever you want like program, kitchen sink and raccoon.

Portable apps are fairly easy to come up with on a USB stick, and the folder structure is your own. A Xojo app does not need to be in the Applications of Program Files folder to run.

Hello,
besides the problems mentioned above I see another reason not to save data into the installation folder. When multiple users use a system then saving data into the apps installation folder can lead to problems. For example one user can read/change/delete the data of other users. And what happens if one user deletes the app by moving the whole folder to the trash? Then the data (for example preference files, templates, data files etc.) of all users may be lost.
If data generated by the application is saved in each users ApplicationData, then one user can not access the data of other users.

Any app that uses an installer deletes all old files. I’ve had a couple of users save their data into the application folder. Thanks the Gods’ my installer checks the size before removing the old app.

Not true. I use installer always (Windows) and I can stipulate what files to delete when uninstall and can only choose from files I am installing. Naturally, any work files that users create even when they choose to save in the program installed folder, will not be deleted when uninstaller is run. By default, the folder to save work files to is \Documents\MyCompanyName\MyProgramName\ but users have the freedom to choose where they want to save work files,

The thread title:
Why should I store my data in ApplicationData folder and not in the installation dir?

ApplicationData folder.

There are two AppData folder:
LocalAppData
RoamingAppData

Both are under the User (Windows login ID). This makes these 2 folders unique to the User. LocalAppData is for data that is local to the machine and the User. RoamingAppData is unique to the User and will roam/sync to the User’s other devices.

Assume a machine is shared by 2 or more users and they use the same program (installed per user, not for all users and data shared). They will have their own unique files in their own unique User folders, therefore how LocalAppData and RoamingAppData are used. Further assume a corporate environment where the machine and desk/seat is shared by employees working in different shift and have different entitlement even though using the same program for their work.

The thing is, both Windows and OS X don’t go quite all the way. They should prevent access to their program folders entirely, like they do for precious system files. As default, Windows entirely prevents access to c:\Windows (the user has to ask permission to gaze), and OS X hides all the unix directories.

The Universe being so clever at inventing better idiots, if any folder is accessible, then chances are someone will put something there. The idiot in question is not always the user, though. There are a number of Windows programs that start the save dialog in the executable directory, or in c:\Program Files.