Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
0
Question by AVividLight · Jul 12, 2011 at 04:22 AM · savefindfileslocaldelete

Accessing the computer's local files

Hey guys,

Sorry about this primitive question, but I can't figure out how to access the computer's local files. I want to-as an example-go into the users photo collection, and gather all the pictures, then display them in a photo album inside Unity. Also, I want to save and delete files from that directory (with the users permission, of course-I'm not trying to make a virus)

I have tried searching for about five minutes and I didn't find anything, so I thought I would ask. Please let me know if this is possible, and if it is, how to do it. Also, an example would be great!

Thanks for your time - Gibson

Comment
Add comment
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

1 Reply

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

Answer by DaveA · Jul 12, 2011 at 04:37 AM

You could try the file:// prefix with the WWW class, but better to check the msdn: http://msdn.microsoft.com/en-us/library/system.io.file.aspx

Comment
Add comment · Show 8 · 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 AVividLight · Jul 12, 2011 at 04:40 AM 0
Share

Well, I am a bit of a novice... Is there a way to do any of those things Unity's Java Script? It says that Java script is not supported. Also, will this work on $$anonymous$$acs?

Also. is it possible to turn the following into a Java Script code?

 public static void $$anonymous$$ove(
 string sourceFileName,
 string destFileName 
 )
avatar image Joshua · Jul 12, 2011 at 04:45 AM 1
Share

Yes, UnityScript uses a port of the .net framework. you can, and should, use all the wonderful methods you can find on msdn.microsoft.com

In this case, System.IO.File is exactly what you want.

avatar image Joshua · Jul 12, 2011 at 04:57 AM 1
Share

Well first of all, you're using an other namespace. So at the top of your script you write:

import System.IO;

then the $$anonymous$$ove function in javascript would be: static function $$anonymous$$ove( sourceFileName : String, destFileName : String );

Read up on the examples, try to learn very basic C# so you can translate it into JS, and you're golden. The examples are very good on $$anonymous$$SDN. The one for this method shows you need to give it two paths, for intance @"c:\temp\$$anonymous$$yTest.txt" and it will move the File from the first path to the second.

avatar image Joshua · Jul 12, 2011 at 05:05 AM 1
Share

Once you import System.IO; you can use all methods within it directly. So yes, you can write:

 var pathOne : String = "...";
 var pathTwo : String = ".......";
 File.$$anonymous$$ove( pathOne, pathTwo );

and you're done. This is why the dot net framework is so extremely nice. It allows you to do nearly anything.

avatar image Graham-Dunnett ♦♦ · Jul 12, 2011 at 09:46 AM 1
Share

But remember that accessing the file system is not supported if you are building a web player.

Show more comments

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

deleting the content of a directory using javascript. 0 Answers

Change Playerpref location directory 0 Answers

Asset Bundles - loading locally and few questions 0 Answers

C# Array problems 2 Answers

Unity Serializer - saves delete after restarting game 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