Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Create image file from Text field
Message
De
10/09/2014 02:38:07
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
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:
01607266
Vues:
28
I don't think you need any encoding at all.

If it comes from a memo field
string query = "SELECT cast(memofieldname as blob)as memofieldname  FROM ...";
The result should give the file contents as is

>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();
>
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform