Can I extract a file from the general foxpro field?

I am migrating a VFP 9 application to SQL Server. A VFP application has several tables with “common” fields in them. I get an array of bytes when I request a field, and when I save it to disk, I can look inside and see it in a text document or BMP Paint, etc.

From reading, I found that the common field is a proprietary format and contains a thumbnail image of the preview document (among other things, I'm sure).

Can someone point me to some code that will first extract the file type and then the actual file data that I can save as the source file. (Getting a preview image would be nice too.)

Apparently, on the same day, someone wrote a program in foxpro called GENTOFIL.PRG, which sounds like it converts common fields into a file. But, google does not help trying to find it!

+3
source share
2 answers

If you know that the contents of the General field is a Word document, I have Visual FoxPro code recommended by someone who needs to extract it.

* First create a form programmatically
loForm = CREATEOBJECT ("Form") 

* Open your VFP table with the general field. Change name as needed
USE CustomerDocs.DBF IN 0 ALIAS WordData

loForm.AddObject ("oleWordDoc", "oleBoundControl") 
loForm.oleWordDoc.AutoSize = .T. 

* bind general field to oleboundcontrol 
loForm.oleWordDoc.ControlSource = "WordData.gen1" 

lnCounter = 1

SCAN 
   * File names all the same with counter at end
   * You might have file name in another column in the table.
   lcFileName = "docfromgeneralfield" + TRANSFORM(lnCounter)
   lcFileName = FORCEEXT(lcFileName, "doc")

   * save data from general field to .doc file 
   loForm.oleWordDoc.SaveAs("lcFileName") 

   lnCounter = lnCounter + 1 
ENDSCAN 

RELEASE loForm

USE IN (SELECT("WordData"))

RETURN

, Microsoft KB, .

http://support.microsoft.com/kb/894819

Visual FoxPro MVP

+4

"" VFP - ...

VFP:

General : , , . , , , OLE .

OLE, , . OLE , , , . .

, "" VFP Microsoft OLE, , . , VFP OLE , OLE / OLE "" .

, , , , , , VFP , .

+3

All Articles