【发布时间】:2016-05-19 08:23:25
【问题描述】:
我在使用 Android 和 Unity 3D 时遇到问题。我有一个文件读取代码。当我把我的代码放在电脑上时,它就可以工作了。但是,我的代码不适用于 Android(移动)。我怎么解决这个问题?谢谢。
FileInfo theSourceFile = new FileInfo(filename);
if (System.IO.File.Exists(fname))
{
StreamReader reader = theSourceFile.OpenText();
string text = reader.ReadLine();
print(string);
}
编辑更新代码
string filename = "file.txt";
FileInfo theSourceFile = new FileInfo(filename);
filename = Application.persistentDataPath + "/"+filename;
System.IO.File.WriteAllText(filename,"Test");
if (System.IO.File.Exists(filename))
{
StreamReader reader = theSourceFile.OpenText();
string text = reader.ReadLine();
print(string);
}
【问题讨论】:
-
filename在哪里定义?它是什么样子的?发布网址是怎样的
标签: android file mobile unity3d apk