Corrupted file saved from Blob field ??!!!

marcidumi
Member Posts: 9
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
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
0
Comments
-
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."0 -
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,
Marcel0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions