>I am working on a conversion to .NET from FoxPro. In Foxpro we had a function called FILETOSTR() which read a file, and did not do any conversion of the file. We also had STRTOFILE() which would take any string and without conversion save it to a file.
>
>Here is what we did with these functions, we could read a Word Doc, or Excel sheet, save it to a text field in an SQL Server database and then retrieve that document, etc. and open it in Word or Excel.
>
>Well, I'm trying to reproduce this in C#, and the function that was provided in the VFPToolkitNET only seems to work with text strings, but when you attempt to open a Word Document it modifies the contents. See code below:
>
> public static string FileToStr(string cFileName)
> {
> //Create a StreamReader and open the file
> StreamReader oReader = System.IO.File.OpenText(cFileName);
>
> //Read all the contents of the file in a string
> string lcString = oReader.ReadToEnd();
>
> //Close the StreamReader and return the string
> oReader.Close();
> return lcString;
> }
>
>How can I reproduce this functionality in C# without modifying the contents of the file upon reading it? Thanks!!
>
>bob
VFPToolkitNet though is good for starters, some functions implementations are not right or doesn't match with the behaviours of VFP counterpart.
string fileName = @"c:\my folder\anyTypeFile.ext";
byte[] fileContent = File.ReadAllBytes(fileName);
PS: For large files you may prefer to do buffered reads.
Cetin