Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
3
Question by CgShady · Nov 17, 2011 at 06:27 PM · windowsfilesystemdirectorydocuments

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

Comment
Add comment · Show 1
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 jahroy · Nov 17, 2011 at 07:33 PM 0
Share

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...

2 Replies

· Add your reply
  • Sort: 
avatar image
12
Best Answer

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.

Comment
Add comment · Show 3 · 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
avatar image CgShady · Nov 17, 2011 at 09:25 PM 1
Share

Thanks! That worked just perfect, on $$anonymous$$acOSX too !

avatar image Aleron · Nov 17, 2011 at 09:28 PM 0
Share

You're welcome. If you could accept the answer (click the little check next to the answer), that'd be great. :)

avatar image numberkruncher · May 01, 2014 at 04:02 PM 0
Share

This was unexpected, wow! it actually works on OS X!! I am using SpecialFolder.ApplicationData and it works a treat. Thanks :)

avatar image
2

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.

Comment
Add comment · Show 1 · 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
avatar image LoungeKatt · Aug 01, 2019 at 08:47 PM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

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


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