Corrupted file saved from Blob field ??!!!

marcidumimarcidumi Member Posts: 9
edited 2003-08-19 in Navision Attain
Hi,

What I am trying to do is to save a Word doc into a blob field and extract back to a file to read using Word. Easy ...! :shock: :arrow: :arrow:

The file resulted is corrupted:

// - Save a Word Document in a Blob File
// Update the BLOB Field (Document) in the Table


FI.OPEN(strPath); // My Word Doc File
FI.CREATEINSTREAM(NVInStream);

Document.CREATEOUTSTREAM(NVOutStream);
WHILE NOT (NVInStream.EOS()) DO BEGIN
Written := NVInStream.READ(readVar,250);
NVOutStream.WRITE(readVar,250);
END;


// I am extracting the Blob file back to the harddisk
// (Word Doc) saved previous



CALCFIELDS(Document);

FO.CREATE('C:\MyDoc.Doc');
FO.CREATEOUTSTREAM(NVOutStream);

Rec.Document.CREATEINSTREAM(NVInStream);
WHILE NOT (NVInStream.EOS()) DO BEGIN
Written := NVInStream.READ(readVar,250);
NVOutStream.WRITE(readVar,250);
END;
FO.CLOSE();


// The file resulted is corrupted - Word faills to open and the new size of the file created is greather then the original
// Something I am doing wrong but I don't know what.


Thanks,
Marcel

Comments

  • eromeineromein Member Posts: 589
    Could you please try this with different word documents.

    I had a case a time ago, that only few document got corrupted. The rest of the docs work fine after exporting.

    btw, I'll try to find out if the guy who made that import export thingy did it the same way you did.
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • marcidumimarcidumi Member Posts: 9
    Basicaly I am saving any type of files in the blob field to be abble to open later (Attachement files e.g. to purchase/sales orders in Navision).

    I have the same problem with excels files and bitmaps and ....

    I dont know where is inserting extra characters when I save in the blob or when I save back from blob.


    Thanks for your reply,
    Marcel
Sign In or Register to comment.