Jump to content

How do I make a file?


Recommended Posts

With the advent of .15 and the IO namespace forbidden... how do you write to a file? I have a Dictionary<string, int> that\'d I\'d like to write to and read from, but I can\'t figure out how to do it with the new API.

In the past I used a BinaryFormatter to serialize it to a file, but that requires streams from System.IO. Is there a drop-in replacement, or will I need to do something else?

Link to comment
Share on other sites

With the advent of .15 and the IO namespace forbidden... how do you write to a file? I have a Dictionary<string, int> that\'d I\'d like to write to and read from, but I can\'t figure out how to do it with the new API.

In the past I used a BinaryFormatter to serialize it to a file, but that requires streams from System.IO. Is there a drop-in replacement, or will I need to do something else?

You can serialize it using IOTools and then write it to disk with File.WriteAllBytes.


byte[] buffer = IOTools.SerializeToBinary(dictionary);
File.WriteAllBytes<SomeClassInYourPlugin>(buffer,'filename.bin');

The serialize/deserialize methods in IOTools use BinaryFormatter.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...