Export Item Picture

HI Guys

I am trying to export the item picture using the below code.But it gives error.

item.GET(‘70000’);

FileName.CREATE(‘E:’+’’+‘ASN’+’.BMP’);

FileName.WRITEMODE(TRUE);

FileName.OPEN(‘E:’+’’+‘ASN’+’.BMP’);

//FileName.TEXTMODE(true);

IF item.Picture.HASVALUE THEN

item.CALCFIELDS(item.Picture);

//FileName.CREATEOUTSTREAM(item.Picture);

FileName.WRITE(item.Picture);

FileName.CLOSE;

Could Please help me what i am doing wrong.

I am not using Item.Picture.Export because i am using a page to export item picture.

Thanks

Naveen

Look at these post

viewtopic.php?t=927
viewtopic.php?t=8356
viewtopic.php?f=14&t=11505
viewtopic.php?t=682
viewtopic.php?f=1&t=661

I’m not sure if the HASVALUE works BEFORE the CALCFIELDS on the BLOB. I’m usually do it other way round.

And your code would fail already on creating the file:
If you want to create a file :
File.Create(‘E:\ASN.BMP’) would work
Your code tries to create the following file : E:\ASN.BMP
And this definitely fails.

Next: Are you sure that you want to export the file to the server? Or do you want to save it at the client machine?
In this case you should use “DOWNLOADFROMSTREAM” like with the following code:


item.GET('70102');

item.CALCFIELDS(Picture);

IF item.Picture.HASVALUE THEN BEGIN
Item.PICTURE.CREATEINSTREAM(InStrm);
DOWNLOADINTOSTREAM(InStrm, 'Save image', 'E:\', '*.bmp', '');
END;