Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Create image file from Text field
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Create image file from Text field
Versions des environnements
Environment:
C# 4.0
OS:
Windows Server 2008
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01607213
Message ID:
01607213
Vues:
46
I have a Text field in the database (populated from VFP Memo field) that contains the file contents.
In VFP they get created FILETOSTR() and retrieved STRTOFILE(), which works without problems.

Now in a C# solution I need to pick up the file contents and copy them to a file, but the resulting file is not valid. I am not sure what is the missing piece in the code:
String fileName;
fileName = Path.Combine(System.IO.Path.GetTempPath(),
              "Samplefile.jpg");

if (System.IO.File.Exists(fileName) == true)
  {
     System.IO.File.Delete(fileName);
  }

FileStream oFs = new
          FileStream(fileName, FileMode.CreateNew, FileAccess.ReadWrite);

StreamWriter oWriter = new StreamWriter(oFs);

ASCIIEncoding asciiEncoding = new ASCIIEncoding();
oWriter.Write(asciiEncoding.GetBytes(reminderMainRow.reFile)); //That is the memo field.
oWriter.Flush();
oWriter.Close();
oFs.Close();
Christian Isberner
Software Consultant
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform