C#实现文件的读写的两个方法
private void WriteTestFile(string filename, string data) { FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write); byte[] buffer = System.Text.Encoding.UTF8.GetBytes(data); fs.Write(buffer, 0, buffer.Length); fs.Close(); } private string ReadTestFile(string filename) { FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read); byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, (int)fs.Length); fs.Close(); string str = System.Text.Encoding.UTF8.GetString(buffer); return str; } public static string LoadFile(string filePath){ string url = Application.streamingAssetsPath + "/" + filePath; #if UNITY_EDITOR return File.ReadAllText(url); #elif UNITY_ANDROID WWW www = new WWW(url); while (!www.isDone) { } return www.text; #endif }
相关推荐
-
通用根据链接生成二维码类 csharp
2019-1-7
-
.net core多层架构增删改查简单封装 csharp
2019-1-8
-
EntityFrameworkCore实现复杂数据关系绑定 csharp
2019-1-8
-
C# WinForm 取运行目录 csharp
2019-1-7
-
c#图片压缩处理 csharp
2019-1-7
-
C#合并图片、图片等比缩放 csharp
2019-1-7
-
RSA加密解密及RSA签名和验证 csharp
2019-1-8
-
rsa加签验签 csharp
2019-1-7
-
C#获取摄像头画面 csharp
2019-1-8
-
针对System.Data.SQLite的数据库常规操作封装的通用类 csharp
2019-1-7