Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create image file from Text field
Message
From
10/09/2014 02:38:07
 
 
To
09/09/2014 11:53:22
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 4.0
OS:
Windows Server 2008
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01607213
Message ID:
01607266
Views:
27
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform