• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by cstlmode · Jun 24, 2016 at 05:02 AM · androidwwwserializationxmlxmlserializer

ArgumentException: Path is empty while saving data in an XML

enter code herehello , i've been stuck with t$$anonymous$$s for days , can someone give me a little insight on what is causing t$$anonymous$$s .
when ever i trigger Save() by $$anonymous$$tting a button ,i get t$$anonymous$$s error , i would like to $$anonymous$$ghlight that data are saved on pc even when t$$anonymous$$s error popup , but on android not$$anonymous$$ng 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();
  
            }
  
  
  
  
        }
 }
  



Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Loading Xml file issues 0 Answers

How to read xml file on Android using www and StreamingAssets? 2 Answers

ScriptableObject+XmlSerializer=sad 2 Answers

Deserializing data with XML Serializer 0 Answers

Guys please help me!!how to download xml file from url in android device runtime 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges