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
2
Question by DrProgrammer · Jan 20, 2011 at 11:15 AM · listpathcustomfiles

Getting list of files from specified folder

Hi everybody!

How can i get ALL the files from custom path(non-unity assets folder) into array, or some kind of list?

P.S. Sorry for my bad English.

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

2 Replies

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

Answer by _MGB_ · Jan 20, 2011 at 11:43 AM

In C# you can do it with:

 using System.IO;
 
 DirectoryInfo dir = new DirectoryInfo(myPath);
 FileInfo[] info = dir.GetFiles("*.*");
 foreach (FileInfo f in info) 
 {
     ...
 }
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 DrProgrammer · Jan 20, 2011 at 11:47 AM 0
Share

Thank you, didnt see it, because i was already writing an JS-oriented answer.

I'm sure that your answer will be useful for C# users in Unity.

avatar image
6

Answer by DrProgrammer · Jan 20, 2011 at 11:44 AM

I got my answer suddenly.

Here it goes:

In the top of the js script

 import System.IO;

And in the function

 var filePaths : String[] = Directory.GetFiles("C:/Users/Altair-X/Music/","*.mp3");

Where "filePaths : String[]" - is an array of string, which contains paths to the files.

"C:/Users/Altair-X/Music/" - where to look for.

"*.mp3" - what to look for.

Comment
Add comment · Show 5 · 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 Adder_Astros · Mar 15, 2014 at 04:55 PM 0
Share

import? I didn't know you could do that with Unity JS! It... it's like a whole new world of possibilities has been opened up to me! I've been looking all over for that! Thank You!

I'd vote thumbs up, but I have no reputation. I'm sketchy.

avatar image TheFloatingSheep · Jan 23, 2016 at 04:48 PM 1
Share

$$anonymous$$an, i'm from the future. Year 2016. I wanted to tell you that... I LOVE YOU DUD$$anonymous$$

avatar image jamqdlaty TheFloatingSheep · May 01, 2020 at 12:49 PM 0
Share

You call this "future"? Pff, amateur. ;)

avatar image Goubermouche jamqdlaty · Aug 30, 2020 at 09:00 AM 0
Share

amateurs :D

avatar image kinggamedev · Apr 24, 2016 at 05:44 AM 0
Share

this work perfect just i need to change capital latter S to small s in string and work. thanks.

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

A node in a childnode? 1 Answer

Get list of all files in a directory? 3 Answers

Android file path? 0 Answers

Build data path and projects data path on postprocess build. 0 Answers

Writing Editor Script, Getting Weird Null Reference Exception 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