/// <summary>
/// Write the specified file, creating all the subdirectories in the process.
/// </summary>
static public bool WriteFile (string fileName, byte[] data)
{
#if !UNITY_WEBPLAYER && !UNITY_FLASH && !UNITY_METRO && !UNITY_WP8
if (data == null || data.Length == 0)
{
return DeleteFile(fileName);
}
else
{
try
{
string dir = Path.GetDirectoryName(fileName);
if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir)) Directory.CreateDirectory(dir);
File.WriteAllBytes(fileName, data);
return true;
}
catch (System.Exception) { }
}
return false;
#endif
}
/// <summary>
/// Read the specified file, returning all bytes read.
/// </summary>
static public byte[] ReadFile (string fileName)
{
#if !UNITY_WEBPLAYER && !UNITY_FLASH && !UNITY_METRO && !UNITY_WP8
try
{
if (File.Exists(fileName))
return File.ReadAllBytes(fileName);
}
catch (System.Exception) { }
#endif
return null;
}
/// <summary>
/// Delete the specified file, if it exists.
/// </summary>
static public bool DeleteFile (string fileName)
{
#if !UNITY_WEBPLAYER && !UNITY_FLASH && !UNITY_METRO && !UNITY_WP8
try
{
if (File.Exists(fileName))
File.Delete(fileName);
return true;
}
catch (System.Exception) { }
return false;
#endif
}