Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create image file from Text field
Message
From
09/09/2014 11:53:22
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Create image file from Text field
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:
01607213
Views:
44
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
Next
Reply
Map
View

Click here to load this message in the networking platform