- Home /
writing to file
Just found FileUtil.ReplaceFile in the documentation. I know unity accepts web-addresses in path-names which should make downloads possible with that command. Is there also a way to save (raw-)data with a similar method? E.g. saving some variable's content to standard-filetypes.
Syntax:
static function ReplaceFile ( src : String, dst : String ) : void
In other words: Is there a way to refere to some kind of internal data with the src-string?
Thanks in advance.
Answer by CursedScripter · Dec 24, 2011 at 03:51 PM
http://answers.unity3d.com/questions/181172/dat-file-location.html
I think you mean something like that
Answer by spacepilot · Dec 24, 2011 at 05:41 PM
I saw the other post already - they use some standard-.NET-method to write to a file. AFAIK it has two disadvantages:
It cannot be used in standard-scripts (only in editor-scripts, please correct me if I'm wrong)
It only writes txt-files (one line at a time)
You cannot output non-.txt-files with that, even though they gave their file a .dat-extension in the example. What I wanna do is using unitys copy-function for files to copy a data-stream instead of a file. So instead of a file-path I wanna give it something else. In linux-world they use the "|" (pipe-symbol) and block-devices for things like that. So my question is what else can I use as pathname? Are there special system-variables or keywords I can use?
Here, someone is using a library called System.io with the command
import http://System.IO;
So obviously someone used a webaddress ins$$anonymous$$d of a pathname to refer to some internal library. I think the idea is close that something like this also works with the copy-function and not only with import. So how can I dump raw-data to a file in unity?
These guys here have had a similar threat: Implement file-compression. Unfortunately it's hard to understand what they are actually talking about. Example:
Using the System.IO.Compression.GZipStream classes results in the dreaded DllNotFoundException: $$anonymous$$onoPosixHelper exception
All I understand is that they also use System.IO to make their compression possible somehow. In a linked threat in the mentioned one, someone writes:
the reason for this failure is not so much the old mono version shipped with Unity 2.6.1, but rather that $$anonymous$$ono implements System.IO.Compression.GZipStream not with a managed implementation, but it relies on a system installed zlib ins$$anonymous$$d.
...so System.IO is some-kind of mono-class with sub-components (here Compression.GZipStream). I don't understand why this website claims System.IO to be a .NET-class. The link is from the compression-threat as well: Using GZipStream for Compression in .NET
So where can I look up this System.IO and what is it anyway? Can I also refere to other things in the same way as with http://System.IO?
Edit2: It seems it's a forums-system-bug: System. I O always gets replaced with http://System.io here. So maybe there is no way to refere to local, internal sources with a webaddress in unity. Would like to get some reply on this. Thank you.
Your answer
![](https://koobas.hobune.stream/wayback/20220613062346im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Facebook cannot find my Unity data file. 1 Answer
[Closed] Place to store user data 1 Answer
Convert Android URI to a file path Unity can read 2 Answers
Out put data from web version 2 Answers