- Home /
Creating a Directory in "My Documents"
I am trying to make a directory in the "My Documents" folder for the current user on windows, to later save some files in it.
It seems there's no system variable to get to this directory.
What would be the best approach to do this ? Do I have to read environment variables ? How would I do that then ?
Thanks
You probably have to find it yourself or use the .Net libraries to do it.
You can pretty much do anything you can do with .Net.
I'm not sure if you have permission to create files in "$$anonymous$$y Documents", though...
Answer by Aleron · Nov 17, 2011 at 08:50 PM
You get can the path by using:
System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
System.Environment also provides access to several other special folders as needed.
Thanks! That worked just perfect, on $$anonymous$$acOSX too !
You're welcome. If you could accept the answer (click the little check next to the answer), that'd be great. :)
This was unexpected, wow! it actually works on OS X!! I am using SpecialFolder.ApplicationData
and it works a treat. Thanks :)
Answer by eem · Nov 17, 2011 at 07:48 PM
https://www.google.com/search?sourceid=chrome&ie=UTF-8&q=get+my+documents+folder+c%23
Since unity uses C#, and supports a good amount of the .NET libraries, just googling "whatever question C#" will typically get you an answer when dealing with non-unity specific things.
When you do this though, pay attention to what classes your solution is using, as Unity does not have every .NET class in it.
I know this answer is rather old, but it also depends on your "Api Compatibility Level" in the "Other Settings" of your "Player Settings" when dealing with random .NET classes.
In general, it is good to search https://forum.unity.com first and Google if you don't find anything there. No need to concern yourself with compatibility if you don't have any reason.
Your answer
Follow this Question
Related Questions
Application Support / LocalApplicationData 2 Answers
Accessing local system ( File Browser ) 2 Answers
How to create a list of prefabs when given path in project directory 1 Answer
EditorUtility.OpenFilePanel uses \ FileInfo.Name uses / 0 Answers
Application.CaptureScreenshot() on iOS not creating file. 2 Answers