using System.Collections; using System.Collections.Generic; using System.Xml; using UnityEngine; public class read_excle : MonoBehaviour { // Use this for initialization void Start() { path = GetSAPath(); string str = GetWebUrl(); print("GetWebUrl:" + str); } // Update is called once per frame void Update() { } private string path = string.Empty; public string GetSAPath() { /* path = "jar:file://" + Application.dataPath + "!/assets/" + "/demo.xlsx";*/ #if UNITY_EDITOR path = Application.dataPath + "/StreamingAssets" + "/demo.xlsx"; #elif UNITY_IPHONE path = Application.dataPath +"/Raw"+"/demo.xlsx"; #elif UNITY_ANDROID path = "jar:file://" + Application.dataPath + "!/assets/" + "/demo.xlsx"; #endif /* //安卓平台 加文件名 #if UNITY_ANDROID && !UNITY_EDITOR path = Application.streamingAssetsPath + "/" #elif UNITY_IPHONE && !UNITY_EDITOR path = @"file:///" + Application.streamingAssetsPath + "/"; #elif UNITY_STANDLONE_WIN || UNITY_EDITOR path = @"file:///" + Application.streamingAssetsPath + "/"; #endif*/ return path; } //读取XML文件的方法 public string GetWebUrl() { string filepath = path; //Application.StartupPath表示exe文件所在的位置。 bool exists = System.IO.File.Exists(filepath); print(exists); if (exists) { /* DataSet ds = new DataSet(); ds.ReadXml(filepath); string strNumber = ds.Tables["webInfo"].Rows[0]["url"].ToString();*/ //return strNumber; return "000"; } else { return "No url!"; } } }