|
@@ -49,8 +49,41 @@ public class FileManager
|
|
}
|
|
}
|
|
|
|
|
|
//读取文件
|
|
//读取文件
|
|
- public void OpenFile()
|
|
|
|
|
|
+ public static void OpenFile()
|
|
{
|
|
{
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ Testfile openFileName = new Testfile();
|
|
|
|
+ openFileName.structSize = Marshal.SizeOf(openFileName);
|
|
|
|
+ openFileName.filter = "JSON Files (*.json)\0*.json\0"; ;
|
|
|
|
+ openFileName.file = new string(new char[256]);
|
|
|
|
+ openFileName.maxFile = openFileName.file.Length;
|
|
|
|
+ openFileName.fileTitle = new string(new char[64]);
|
|
|
|
+ openFileName.maxFileTitle = openFileName.fileTitle.Length;
|
|
|
|
+ openFileName.title = "选择文件";
|
|
|
|
+ openFileName.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;
|
|
|
|
+ if (DllTest.GetSaveFileName(openFileName))
|
|
|
|
+ {
|
|
|
|
+ string filepath = openFileName.file; //选择的文件路径;
|
|
|
|
+ if (File.Exists(filepath))
|
|
|
|
+ {
|
|
|
|
+ //if (callback != null)
|
|
|
|
+ // callback(filepath);
|
|
|
|
+ //return;
|
|
|
|
+ }
|
|
|
|
+ Debug.Log(filepath);
|
|
|
|
+ string json = File.ReadAllText(filepath);
|
|
|
|
+ jsonData data = JsonUtility.FromJson<jsonData>(json);
|
|
|
|
+ Debug.Log(data.ProjectName);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e)
|
|
|
|
+ {
|
|
|
|
+ Debug.LogError(e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //if (callback != null)
|
|
|
|
+ // callback(string.Empty);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|