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 Gf15a4 · Apr 18, 2015 at 10:12 PM · filesaving

Read and write to huge files

I need the ability to read and write to huge files without reading ALL of the lines and opening ALL of the lines. I need 10,000,000,000 floats to use real time, but I can't do float[] terrainVertices = new float[10,000,000,000] simply because of memory issues. I thought to myself I can read and write to a file, but theres no way without reading all data from file and that calls for creating an array of loaded data into an array(back to square one). I found out about memorymappedfile and I thought all my problems were solved until it turns out it was a .net 4.0 and above feature. Is there any solution in the current mono version or is there any way i can use memorymappedfiles in the current version or upgrade to 4.5 inside unity?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by karljj1 · Apr 18, 2015 at 10:47 PM

You don't need to read the entire file if you only want a sample of the contents. Providing you know where in the file your data is then you can seek to that position and read at that point. If your file contains nothing but floats then its easy to know where in a file you need to seek to e.g index * size of float(4)

Use the seek function. http://www.dotnetperls.com/seek

Comment
Add comment · Show 3 · 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 Gf15a4 · Apr 18, 2015 at 11:04 PM 0
Share

Can you give me an example on how to read and write using seek. I want to read and write to a specified line in txt file. I looked up "how to read and write one line" and all the answers simply said you cant without loading and saving the whole file again.

avatar image karljj1 · Apr 18, 2015 at 11:19 PM 0
Share

Your storing your floats as strings? That will make it harder to know where in the file to look as a string version of a float is not a fixed size like a binary version.

Here's a link http://forums.asp.net/t/1530644.aspx?How+to+insert+update+a+text+file+content+in+C+

avatar image Gf15a4 · Apr 18, 2015 at 11:24 PM 1
Share

I now understand what you are talking about, I used to just load everything from txt file but now im understand how to use stream and its features and it has everything I need. Thanks a lot :)

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

19 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

Related Questions

[Closed] Place to store user data 1 Answer

trying to store to json 1 Answer

Loading a saved Game 1 Answer

How to add existing xml file to project build? 1 Answer

When writing a txt file, it says sharing violation 3 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