-
December 26th, 2012, 09:36 PM
#1
-
December 27th, 2012, 02:44 AM
#2
Re: Trying to dump an "unsigned char" array to file!
Originally Posted by fernando306
Hi there! How are you?
Fine. (For the unlikely case this question is actually meant for me... )
Looks like what you actually want is a FileStream rather than a StreamWriter. Like this:
Code:
String ^fileName = "textfile.txt";
FleStream ^fs = gcnew FileStream(fileName, FileMode::Create);
fs->Write(array3, 0, array3->Length);
fs->Close();
Already the first line of the MSDN StreamWriter doc page could have been a useful indicator that this isn't what you actually want, BTW:
Originally Posted by MSDN
Implements a TextWriter for writing characters to a stream in a particular encoding.
[...] And ah! After I succeed writing it, how to read it back??
Reading it back is much like writing it; you'd even use the same framework class. Just study the MSDN docs.
However, if what you actually want is text file handling, a StreamWriter may very well be what you're looking for. It just doesn't have a Write(array<unsigned char> ^) overload (the C++ unsigned char is equivalent to the .NET System::Byte). Appropriate objects to pass to TextWriter::Write() are, among others, array<System::Char> ^ (note the capital C, where the equivalent native item type is wchar_t rather than unsigned char) or simply System::String ^.
BTW, code tags?
Last edited by Eri523; December 27th, 2012 at 12:21 PM.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
December 27th, 2012, 11:34 AM
#3
Re: Trying to dump an "unsigned char" array to file!
Hi Eri523! Thank you so much for your help. I'll definitively study the FileStream class and implement it. No, I'm not handling text files, so you surely saved me from a lot of headaches
Oh yeah! Code tags!
I'll get back here ASAP. Happy Xmas BTW!
-
December 27th, 2012, 03:50 PM
#4
Re: Trying to dump an "unsigned char" array to file!
Hey Eri523!
I used FileStream and it worked 100% fine. I also used OpenFileDialog and SaveFileDialog to browse directories and provide the file path. It was a piece of cake!
Thanks a lot, your suggestion was great!
Best wishes,
Fernando
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|