Copystream on BLOB fields

haksvehaksve Member Posts: 17
I Try to add all the blobreferences in Table "Objects" into a file. However the Copystream command causes MBS NAV (5.1) to crash. any ideas?


FilePath := 'C:\QQQ\CCChecksum.BIN';

DestinationFile.WRITEMODE(TRUE);
DestinationFile.TEXTMODE(FALSE);
DestinationFile.CREATE(FilePath);
DestinationFile.CREATEOUTSTREAM(Outstr);
ObjectTable."BLOB Reference".CREATEINSTREAM(Instr);

ObjectTable.RESET;
ObjectTable.SETFILTER(Type,
'%1|%2|%3|%4|%5|%6|%7',
ObjectTable.Type::Table,
ObjectTable.Type::Form,
ObjectTable.Type::Report,
ObjectTable.Type::Dataport,
ObjectTable.Type::Codeunit,
ObjectTable.Type::XMLport,
ObjectTable.Type::MenuSuite
);

ObjectTable.FINDSET;
REPEAT
ObjectTable.CALCFIELDS(ObjectTable."BLOB Reference");
IF ObjectTable."BLOB Reference".HASVALUE THEN BEGIN
IF NOT COPYSTREAM(Outstr,Instr) THEN
ERROR('COPYSTREAM failed');
END;
UNTIL ObjectTable.NEXT = 0;

Comments

  • ara3nara3n Member Posts: 9,256
    why not do the following

    if object.findset then repeat
    object.calcfields(Blob reference");
    object.export('c:\object.file',false);
    until object.next = 0;
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • garakgarak Member Posts: 3,263
    What's the reason, that you need this?
    Are there in the file only the BLOB reference or some more?
    If the BLOB Ref. is only in the file use ara3n's solution.

    If you want to stream more in the file, try this:
    RecObject.GET(5,'',1);
    RecObject.CALCFIELDS(RecObject."BLOB Reference");
    if RecObject."BLOB Reference".HASVALUE then begin
      Myfile.CREATE('C:\Downloads\zzzz.txt');
      //Myfile.SEEK(TheNeededPosition);
      RecObject."BLOB Reference".CREATEInSTREAM(IStream);
      Myfile.CREATEOutSTREAM(OStream);
      COPYSTREAM(OStream,IStream);
      Myfile.CLOSE;
    end;
    

    Regards
    Do you make it right, it works too!
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV Tips & Tricks' forum to 'NAV/Navision' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • haksvehaksve Member Posts: 17
    Answer to Garak:
    The reason is that I will use the file to calculate a checksum for the total of all objects.
    As far as I can see Your suggestion is doing the same thing as my code, execept that my code loops and concatenates all the blob references

    Best Regards
  • haksvehaksve Member Posts: 17
    Answer to ara3n:
    The export function will overwrite the file instead of adding to it.

    Best Regards
Sign In or Register to comment.