Search Unity

Error: 'WriteAllBytes' is not a member of 'System.IO.File'

Discussion in 'iOS and tvOS' started by RedRocks, Oct 31, 2008.

  1. RedRocks

    RedRocks

    Joined:
    Oct 27, 2008
    Posts:
    23
    Getting this error when using WriteAllBytes - ERROR: 'WriteAllBytes' is not a member of 'System.IO.File'.

    Is there a work-around or alternative method in iPhone Unity?

    Thanks
     
  2. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    Yeah, that version of Mono doesn't have that convenience function. But you can do something like this snippet:
    Code (csharp):
    1. import System.IO;
    2.  
    3. var fs : FileStream = FileStream(path, FileMode.CreateNew);
    4. var w : BinaryWriter = BinaryWriter(fs);
    5. w.Write(bytes);
    6. w.Close();
    7. fs.Close();
    Cheers,
    -Jon
     
  3. Andrew Enquist

    Andrew Enquist

    Joined:
    Jun 22, 2011
    Posts:
    6
    Thanks Jonathan, I was looking for this