Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reading and writing files in c#
Message
De
31/03/2009 13:21:00
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Reading and writing files in c#
Divers
Thread ID:
01392440
Message ID:
01392440
Vues:
118
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform