Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

mdsn GetFiles function doesnt want to compile.

Discussion in 'Editor & General Support' started by frogsbo, Sep 5, 2014.

  1. frogsbo

    frogsbo

    Joined:
    Jan 16, 2014
    Posts:
    79
    this works:

    Code (csharp):
    1.   var path1 = System.IO.Directory.GetFiles(Application.dataPath, "c*");
    And this doesnt compile, no function match:

    Code (csharp):
    1.    var path1 = System.IO.Directory.GetFiles(Application.dataPath, "c*", SearchOption.AllDirectories);
    in ,js they should both work, should i send a bugreport to bugs@unity3d. c0m?



    No appropriate version of 'System.IO.Directory.GetFiles' for the argument list '(String, String, System.IO.SearchOption)' was found.
     
    Last edited: Sep 7, 2014
  2. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    You've forgotten to import System.IO.
     
  3. frogsbo

    frogsbo

    Joined:
    Jan 16, 2014
    Posts:
    79
    No i have import System.IO at the top of the .js

    That's why GetFiles(String, String); works and Getfiles(String, String, SearchOption) didnt work.

    If one Getfiles commands runs, the other should, but it doesn't. I have .net framework 4.0 and the directory commands exist since version 2.0.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    Unity doesn't use .NET, so whatever framework you have installed isn't relevant. I expect you have the platform set to webplayer, which doesn't work with System.IO stuff for security reasons.

    --Eric
     
  5. frogsbo

    frogsbo

    Joined:
    Jan 16, 2014
    Posts:
    79
    Do you think that they expressly barred the use of Getfiles .AllSubDirectories because they were worried that someone could gain access to user's documents by sending out a package with a getfiles to retrieve any document files from a computer?

    That's very right of them however the other directory commands should be barred as well.

    Because, why would the compiler recognize one System.IO function in my script and not another one.

    Indeed i get confused about .net implementation in unity, it's written .net 2.0 at the bottom of player settings. (the PC/MAC/Linux of player can't compile it.
     
    Last edited: Sep 7, 2014
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    None of the System.IO commands will actually work in a webplayer; they've expressly barred everything. Not sure about what compiles or not though. Unity uses Mono rather than .NET.

    --Eric
     
  7. frogsbo

    frogsbo

    Joined:
    Jan 16, 2014
    Posts:
    79
    Last edited: Sep 8, 2014