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 /
  • Help Room /
avatar image
0
Question by SUPERDOOMPANDA · Sep 16, 2020 at 08:49 PM · filestream

Error writing CSV file with filestream

Hello, I'm trying to write a file, however, I've come up against this error which I'm a bit stuck on. I've noticed when I pass in a shorter string of text I don't get this error, however, this doesn't help me achieve the results I want for the CSV file. Any help would be greatly appreciated.

CODE:

 //Copied from Datalog class (which passes the string values to the Write CSV class
 
     public void WriteAdventureLog()
     {
        string txtHeader = "RUN,STEP,LOOP CYCLE,PLAYER LVL, PLAYER XP, S-CURRENCY, H-CURRENCY, ACTIVITY, STEPS, KM, INV COUNT, INV COMMON, INV UNCOMMON, INV EPIC, INV RARE, INV LEGENDARY";
        WriteToCSV.AddRecordHeader(txt, "/inventory.csv");
     }
 
 //Copied from Write CSV Class    
         //First row is header for CSV
         public static void AddRecordHeader(string text, string filepath)
         {
             try
             {
                 using (System.IO.StreamWriter file = new System.IO.StreamWriter(filepath, true))
                 {
                     file.WriteLine(text);
                     Debug.Log("Got here");
                 }
             }
             catch (Exception ex)
             {
                 throw new ApplicationException("Could not write to CSV file", ex);
             }
         }
 

ERROR:

UnauthorizedAccessException: Access to the path "/inventory.csv" is denied.

System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) (at :0) System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options, System.String msgPath, System.Boolean bFromProxy, System.Boolean useLongPath, System.Boolean checkHost) (at :0) (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions,string,bool,bool,bool) System.IO.StreamWriter.CreateFile (System.String path, System.Boolean append, System.Boolean checkHost) (at :0) System.IO.StreamWriter..ctor (System.String path, System.Boolean append, System.Text.Encoding encoding, System.Int32 bufferSize, System.Boolean checkHost) (at :0) System.IO.StreamWriter..ctor (System.String path, System.Boolean append, System.Text.Encoding encoding, System.Int32 bufferSize) (at :0) System.IO.StreamWriter..ctor (System.String path, System.Boolean append) (at :0) (wrapper remoting-invoke-with-check) System.IO.StreamWriter..ctor(string,bool) WriteToCSV.AddRecordHeader (System.String text, System.String filepath) (at Assets/Scripts/Utilities/WriteToCSV.cs:31) Rethrow as ApplicationException: Could not write to CSV file WriteToCSV.AddRecordHeader (System.String text, System.String filepath) (at Assets/Scripts/Utilities/WriteToCSV.cs:39) DataLog.WriteAdventureLog (System.String value) (at Assets/Scripts/Utilities/DataLog.cs:58) GUIController.DisplayAdventureLogText (System.Collections.Generic.List`1[T] items) (at Assets/Scripts/Systems/GUIController.cs:56) ChestSystem.WriteAdventureLog (System.Collections.Generic.List`1[T] lootItems) (at Assets/Scripts/Systems/ChestSystem.cs:101) ChestSystem.Encounter () (at Assets/Scripts/Systems/ChestSystem.cs:42) CoreLoop.CheckActionType (LoopAction loopAction) (at Assets/Scripts/Systems/CoreLoop.cs:92) CoreLoop.IntiateLoop (System.Int32 levelsToCycle) (at Assets/Scripts/Systems/CoreLoop.cs:61) SimEnvController.RunEnvironment (System.Int32 levelsToCycle) (at Assets/Scripts/Systems/SimEnvController.cs:23) SimEngine+d__13.MoveNext () (at Assets/Scripts/Systems/SimEngine.cs:58) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) SimEngine:RunSimulation() (at Assets/Scripts/Systems/SimEngine.cs:44) Button:RunSim() (at Assets/Scripts/Systems/Button.cs:23) UnityEngine.EventSystems.EventSystem:Update() (at /Applications/Unity/Hub/Editor/2020.1.1f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:376)
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.

Follow this Question

Answers Answers and Comments

207 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 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 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 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 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 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 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 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 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

EndOfStreamException: Failed to read past end of stream. 0 Answers

*SOLVED* Error writing to IOS file system works on android & editor 1 Answer

How can i save a sprite with FileStream 0 Answers

Roughly how much processing power is needed to loop through string-Lists/Arrays when loading/saving stored data? 0 Answers

How to reference a filepath for streamreader on android device? 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