I know I can get the application data path, but is it possible to get just the application path? I want to have a config file next to the executable file/icon on mac and windows and not in a folder
This is a basic C# question, which applies to all apps. It’s nothing to do with Unity.
These properties were made to avoid the silly responses farting around here.
These are what you asked for:
System.AppDomain.CurrentDomain.BaseDirectory
// Exactly as it says. The Start-up directory of current application. It does not change.
// You never need to cache this as it won't change, but you sure can if you want to.
// Be sure to test this in a build. The editor play mode will give you the editor directory.
System.Environment.CurrentDirectory
// Starting value is BaseDirectory. Can be changed for complex directory operations.
// This is something you can cache several times with each change to save desired paths.
// These are the most correct answers to this question.
// There are some responses here that fart around, and others that make those look good.
I am saddened by the horrendous “answers”.
Here is code you can copy and paste into a MonoBehaviour for testing in a build.
Well, if this were a regular Windows application, I would have told you to just use `Application.StartupPath`, but since it's not (and the Unity library has their own version of the Application class), I don't think what you're asking for is possible.
I'm pretty sure the `dataPath` variable is there for cross-platform compatibility, since the filesystems are different on Windows/Mac/iPhone, etc, so what the `dataPath` does is gives you a unified, safe location where you can store data, regardless of target platform.
Hi, this is an old post, but this is not the solution anymore. Now the datapath leads to “nameApp_Data”, not the folder in which you have your executable.