using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; namespace GeneralTools { public class FileWriter { public static void WriteFile(byte[] data, string path) { if (File.Exists(path)) File.Delete(path); string dir = Path.GetDirectoryName(path); if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); FileStream fs = new FileStream(path, FileMode.Create); StreamWriter streamWrite = new StreamWriter(fs); fs.Write(data, 0, data.Length); fs.Flush(); fs.Close(); } } }