Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
1
Question by kilian277 · Jun 02, 2014 at 06:06 PM · fileexceptionsystem.io

ArgumentException: Name has invalid chars

Hi,

i'm using the following fucntion:

 File.WriteAllBytes(Application.persistentDataPath + "/ingametext.txt",www.bytes);

And it gives me the following error which i find remarking because what is meant with the "Name" ???

 ArgumentException: Name has invalid chars
 System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.IO/FileStream.cs:253)


This is the code i use for extracting every package i need to download from a webserver:

 TextAsset tuneInstall = Resources.Load("tune/install") as TextAsset;
         string install = tuneInstall.text;
 
         //split on newline
         string[] arrPacks = install.Split("\n"[0]);
 
         foreach (string pack in arrPacks)
         {
             if (pack.Contains("package"))
             {
                 string[] splitPack = pack.Split(':');
                 if (!packs.Contains(splitPack[1]))
                 {
                     packs.Add(splitPack[1]);
                 }
             }
         }


And the file looks like this:

 package:ingametext.txt
 package:title.txt
 

Thanks!

Comment
Add comment · Show 7
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
avatar image rutter · Jun 02, 2014 at 06:24 PM 0
Share

Is that the actual code you're using? I've never heard of Application.persistentData, but I have heard of similar properties, which makes me think you've retyped your code.

avatar image Sisso · Jun 02, 2014 at 06:39 PM 0
Share

I didn't get

What Debug.Log(Application.persistentData + "/ingametext.txt") prints and for wich platform are you using? (ex: Android on unity editor).

I usually use

 using (StreamWriter w = new StreamWriter(path)) {
     w.WriteLine(Encrypt(Json.Encode(header)));
 }
avatar image fafase · Jun 02, 2014 at 06:42 PM 0
Share

It seems the main problem comes from the wrong use of persistentData which is not a member of Application class, at least not the Unity one.

avatar image kilian277 · Jun 02, 2014 at 09:37 PM 0
Share

Yea know it was a typo i meant Application.persistentDataPath edited

avatar image rutter · Jun 02, 2014 at 09:48 PM 0
Share

Are you perhaps on a platform where / is not the path separator? You might check if Path.Combine is more successful.

Without more information, this is a stab in the dark.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by tanoshimi · Jun 02, 2014 at 06:31 PM

Do you mean Application.persistentDataPath?

Comment
Add comment · Show 1 · Share
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
avatar image kilian277 · Jun 03, 2014 at 03:40 PM 0
Share

Yea it was a typo i was using that. Now i've used another script for writing the file :

 FileStream fs = new FileStream(sb.ToString(), File$$anonymous$$ode.Create);
         StreamWriter sw = new StreamWriter(fs);
         sw.Write(web.bytes);
 
         sw.Close();
         fs.Close();

And the output path is C:/Users/$$anonymous$$ilian/AppData/LocalLow/BeastGameWare/Exile/ingametext.txt

Generated by this code:

 StringBuilder sb = new StringBuilder();
         sb.Append(Application.persistentDataPath);
         sb.Append("/");
         sb.Append(pack);

And it still gives me the same error , i really dont get it.

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.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

C# How to read and cache text file data? 1 Answer

File exists not working applicationDataPath 1 Answer

WWW and File.Exists to check new file on server 1 Answer

Multiple Lists to CSV in C# 0 Answers

FileNotFound error without description 0 Answers


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