replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - use of MemoryStream
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

use of MemoryStream

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
silverdan



Joined: 14 May 2009
Posts: 29

PostPosted: Wed May 20, 2009 9:57 pm    Post subject: use of MemoryStream Reply with quote

I am wondering how to use .NET's MemoryStream. I know you can use StreamReader similar to this:

Code:
OBJECT("System.IO.StreamReader") StreamReader
ASSEMBLY_EXTERNAL("System.IO.File.OpenText") FileOpen
ASSEMBLY_EXTERNAL("System.IO.StreamReader.Close") StreamReaderClose

StreamReader = FileOpen("c:\text.txt")


I have gotten this far:

Code:

OBJECT("System.IO.MemoryStream") MemoryStream


but how do I turn this part of it into Fortran.Net?

Code:
MemoryStream mStream = new MemoryStream(ASCIIEncoding.Default.GetBytes("Your string here"))
Back to top
View user's profile Send private message
Andrew



Joined: 09 Sep 2004
Posts: 232
Location: Frankfurt, Germany

PostPosted: Thu May 21, 2009 12:10 pm    Post subject: Reply with quote

Something like this:

Code:
PROGRAM TestMemoryStream

OBJECT("ClassLibrary1.Class1") Class1
OBJECT("System.IO.MemoryStream") MemoryStream
OBJECT("System.Text.ASCIIEncoding") ASCIIEncoding
ASSEMBLY_EXTERNAL("System.Text.ASCIIEncoding.GetBytes") ASCIIEncodingGetBytes
ASSEMBLY_EXTERNAL("ClassLibrary1.Class1.ReadStream") ReadStream

ASCIIEncoding = new@("System.Text.ASCIIEncoding")
MemoryStream = new@("System.IO.MemoryStream", ASCIIEncodingGetBytes(ASCIIEncoding,"string"))

Class1 = new@("ClassLibrary1.Class1")
CALL ReadStream(Class1, MemoryStream)

END


with C# like:

Code:
namespace ClassLibrary1
{
    public class Class1
    {
        public void ReadStream(MemoryStream memoryStream)
        {
            string s = "";
            StreamReader streamReader = new StreamReader(memoryStream);
            while ((s = streamReader.ReadLine()) != null)
            {
                Console.WriteLine(s);
            }
        }
    }
}


I did have to play around to get an instance of the ASCIIEncoding class to call GetBytes with an instance of it (which wasnt clear initially). Its much the same as the previous example in many ways - just have a play creating and passing .NET objects in this way and you should get used to it.
Back to top
View user's profile Send private message
silverdan



Joined: 14 May 2009
Posts: 29

PostPosted: Fri May 22, 2009 3:51 pm    Post subject: Reply with quote

That worked perfectly. Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group