Search Unity

`System.IO.File' does not contain a definition for `WriteAllBytes'

Discussion in 'Scripting' started by LVBen, Jan 16, 2016.

  1. LVBen

    LVBen

    Joined:
    Apr 1, 2013
    Posts:
    16
    I just got patch 5.3.1p because of a bug that was in 5.3.1f1 and now I have a new problem:

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

    What happened to this method?

    I'm also now getting these errors:
    error CS1502: The best overloaded method match for `UnityEngine.Texture2D.LoadImage(byte[])' has some invalid arguments
    error CS1503: Argument `#1' cannot convert `object' expression to type `byte[]'
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,539
    Go to build settings and make sure you're not currently targeting the web player.

    Web player doesn't support that method.
     
    LVBen and Kiwasi like this.
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Still remember the first time this got me. It would be nice to have a more platform specific error. Something like "The method you want is not supported on this platform"

    As it was I spent hours reading and rereading System.IO.File ...
     
  4. LVBen

    LVBen

    Joined:
    Apr 1, 2013
    Posts:
    16
    Thank you! That appears to be correct. Something from the installation caused it to automatically switch to Web Player and now I can't even switch back to Windows, though, I'm quite certain I selected only Windows and Android to be installed and not Web Player...

    -----------

    I updated to 5.3.1p3 and installed support for only Windows and Android and then switched from Web Player to Windows and now it is working correctly.
     
    Last edited: Jan 16, 2016
  5. LVBen

    LVBen

    Joined:
    Apr 1, 2013
    Posts:
    16
    To prevent it from happening to me again, I added this to the file that uses those methods:

    #if !UNITY_STANDALONE_WIN
    #warning("This class is intended for the Windows platform only.")
    #endif