Search Unity

System.IO.File error

Discussion in 'Editor & General Support' started by BitFish, Mar 16, 2011.

  1. BitFish

    BitFish

    Joined:
    Nov 5, 2010
    Posts:
    21
    Is anyone else having trouble with the System.IO.File class? Every method I call from that class throws an error. This started happening after I upgraded from Version 3.2 to Version 3.3.

    For instance, when I try to make a call to the File.WriteAllBytes method, I get the following error.

    // error CS0117: `System.IO.File' does not contain a definition for `WriteAllBytes'

    Anyone have any idea what this could possibly be caused by? Is this an issue on my end, or a bug in Unity?

    I submitted a bug report, but I haven't heard anything back and am hoping to get this resolved quickly so I can keep working on this. Thanks!
     
  2. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Make sure you have ".Net 2.0" selected in the Player settings, the default is ".Net 2.0 subset".
     
  3. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    the function works fine even on subset on Unity 3.3 with standalone win - osx players

    Question is what platform you are on.
    On Webplayer it won't work for example and it its possible that UT has now finally taken it out to fire the error right away instead of firing an exception on the build.
     
  4. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    864
    I have the CS0117 error as well.

    My project has two scenes: one for building a standalone and one for building a webplayer. The compiler freaks out ONLY when I try to build the webplayer, as pointed out by dreamora. The webplayer-unfriendly methods (like System.IO.Directory.Move) is not called in the webplayer scene, but they are referenced all over the place, so they will be included in the webplayer build.

    This is a major headache. I have a great deal of data model classes with webplayer-unfriendly methods that are used in both scenes, but not called in the webplayer scene.

    Any handy house keeping tips for cleaning up the mess will be appreciated.

    ~ce
     
  5. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    864
    ...wait! Does this mean that it is no longer possible to have a single project that exports both to web and standalone, while the standalone version takes use of System.IO functionality?

    Please someone let me know that this is possible.

    ~ce
     
  6. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    864
    I'm still struggleling with this and would LOVE if anyone could answer my question.

    ~ce
     
  7. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    864