Forum C# Reading and Writing to text files

Reading and Writing to text files

Postby deadbug » November 9th, 2011, 11:06 pm

Hello,

There seems to be a problem with the following methods:
FileInfo theSourceFile = null;
or
System.IO.FileStream fileStream = new System.IO.FileStream("chathistoryb.txt", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite, System.IO.FileShare.None);

System.IO.StreamReader sr = new System.IO.StreamReader("chathistoryb.txt");

System.IO.StreamWriter sw = new System.IO.StreamWriter("chathistoryb.txt");

When I try to use it I get this outputted on the server:
error: MushroomsUnity3DExample.GameCode.GotMessage(...) has varible of the non-allowed type: System.IO.FileInfo

I'm trying to save chat messages to a text file on the servers side and then load the messages back to everyone once they log back in.

Is there special way to read/write to text files with player io?

Thanks
deadbug
 
Posts: 35
Joined: November 1st, 2011, 1:35 am

Re: Reading and Writing to text files

Postby Henrik » November 11th, 2011, 3:50 pm

The "problem" is that we do not allow you to touch the filesystem on the servers in any way whatsoever. :D

If you want to persist data you should use the BigDB service: http://playerio.com/documentation/refer ... rary.bigdb
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Reading and Writing to text files

Postby deadbug » November 11th, 2011, 8:55 pm

Thank you,

I manged to set up a table to store the needed info and it works. I cant really keep track of single messages as their own thing but I can keep track of the number of messages.
deadbug
 
Posts: 35
Joined: November 1st, 2011, 1:35 am


Return to C#