>>But for a jpg you shouldn't do a conversion. IOW remove conversion from code. Just write it out with BinaryWriter (might do with text as well).
>>PS:UnicodeEncoding was sample and you might use other encodings' GetString() method too. Unicode is 2 bytes per character.
>
>Well, the goal of FileToStr() is to have a universal function that can send me the string equivalent of all kind of files. So, basically, if I do FileToStr("d:\Text.txt") or FileToStr("d:\Logo.jpg"), I need to have the string equivalent. This is why I ended up with FileToStr() and FileToStrBinary() in my framework.
>
>As for VFP's FileToStr(), I read on West Wind board that this function cannot handle binary files and someone else over there ended up in the same situation as me, but from VFP that time. IAC, I did two methods to achieve the same. So, it seems VFP's FileToStr(), based from what I read, cannot accomplish that from one function as it can only work with text files.
>
>However, if you can know how to accomplish a .NET FileToStr() method that would handle all kind of files, that would be appreciated.
Michel,
I don't have a ready one (there is I know but where:), I'll find or write one later.
As per VFP's FileToStr() information is not correct as I read it. It can handle binary files perfectly well (under the covers just does binary reading, not text).
The problem with .Net you're trying to send back a string. A string is not compatible with binary data as I observed and I might be wrong (to say in other terms -if I can:)- serializing a binary data just as string without any encoding like base64 would lead to corruption).
Cetin