- Home /
ArgumentException: Path is empty while saving data in an XML
enter code here
hello , i've been stuck with this for days , can someone give me a little insight on what is causing this .
when ever i trigger Save() by hitting a button ,i get this error , i would like to highlight that data are saved on pc even when this error popup , but on android nothing get saved ,
here is the error i get
ArgumentException: Path is empty System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/FileStream.cs:209) System.IO.FileStream..ctor (System.String path, FileMode mode) (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode) JetpackXmlManager.Save () (at Assets/Resources/JetpackXmlManager.js:45) BoostEUConsumptionProgress.Check () (at Assets/BoostEUConsumptionProgress.js:128) UnityEngine.GameObject:SendMessage(String) ConfirmPayment:Confirm() (at Assets/ConfirmPayment.js:8) UnityEngine.EventSystems.EventSystem:Update()
public class JetpackXmlManager extends MonoBehaviour {
function Awake(){
if(Application.platform==RuntimePlatform.Android)
RootFolder ="jar:file://" + Application.persistentDataPath + "!/assets/XmlFiles/JetpacksDB.xml";
else
RootFolder = Application.dataPath + "/StreamingAssets/XmlFiles/JetpacksDB.xml";
Open();
}
// save function
public function Save(){
var MySerializer :XmlSerializer = new XmlSerializer(typeof(SavedItems) );
var MySaveFile :FileStream = new FileStream(RootFolder,FileMode.Create);
MySerializer.Serialize(MySaveFile,JetpackDB);
MySaveFile.Close();
}
// Open function
public function Open(){
var MySerializer :XmlSerializer= new XmlSerializer(typeof(SavedItems));
var linkstream : WWW ;
if(Application.platform==RuntimePlatform.Android) linkstream = new WWW( "jar:file://"+Application.persistentDataPath +"!/assets/XmlFiles/JetpacksDB");
else linkstream = new WWW("file:///" + Application.dataPath + "/StreamingAssets/XmlFiles/JetpacksDB");
yield linkstream;
if (linkstream.isDone == true) {
var MySaveFile = new StringReader(linkstream.text);
JetpackDB= MySerializer.Deserialize(MySaveFile) as SavedItems;
MySaveFile.Close();
}
}
}