/// <summary> /// /// </summary> /// <param name="vo"></param> /// <param name="fullPath"></param> /// <param name="deflate">是否压缩</param> public static void SaveAMF(object vo, string fullPath, bool deflate = true) { AutoCreateDirectory(fullPath); ByteArray bytesArray = new ByteArray(); bytesArray.WriteObject(vo); if (deflate) { bytesArray.Deflate(); } byte[] bytes = bytesArray.ToArray(); File.WriteAllBytes(fullPath, bytes); }
public static bool save(object o, string fullPath) { ByteArray bytesArray = new ByteArray(); try { bytesArray.WriteObject(o); bytesArray.Deflate(); byte[] bytes = bytesArray.ToArray(); using (FileStream fileStream = File.Open(fullPath, FileMode.Create)) { fileStream.Write(bytes, 0, bytes.Length); } } catch (Exception ex) { Debug.Log(ex); return(false); } return(true); }