Problem with UPLOADINTOSTREAM function

Hi everyone,

I am having a trouble with the following piece of code run from a codeunit:

FileName := 'C:\SomeFile.txt';
ok := UPLOADINTOSTREAM('','<TEMP>','Text Files (*.txt)|*.txt',FileName,NVInStream);
IF ok THEN BEGIN
BLOBRef.Blob.CREATEOUTSTREAM(NVOutStream);
COPYSTREAM(NVOutStream,NVInStream);
EXIT(FileName);
END;
ErrorMessage := GETLASTERRORTEXT;
IF ErrorMessage <> '' THEN
ERROR(ErrorMessage);
EXIT('');

I am always getting the following error message:

Could not find a part of the path 'C:\Users\xxx\AppData\Local\Temp\Microsoft Dynamics NAV\8636\SomeFile.txt'.

I verified, the file ‘C:\Users\xxx\AppData\Local\Temp\Microsoft Dynamics NAV’ does not exist.
How shall I proceed?

Hi,

path 'C:\Users\xxx\AppData\Local\Temp\Microsoft Dynamics NAV\8636\SomeFile.txt'. is the TEMP path for current user,

in / ok := UPLOADINTOSTREAM('','<TEMP>','Text Files (*.txt)|*.txt',FileName,NVInStream); / you shouldnt use TEMP.

I think you have to declare a pathname also and use it instead of .

I need to use temp because I need to upload the file without dialog…

Hi,

Do you still have the error?

Why you don’t use such solution instead of filestreams?

FileName := ‘C:\SomeFile.txt’;

intpos := 1;
FinalText := FileName;
REPEAT
FinalText := COPYSTR(FinalText,intpos+1);
intpos := STRPOS(FinalText,’’);
UNTIL intpos = 0;

COPY(FileName,ENVIRON(‘TEMP’)+’’+FinalText);

Hi Poppins,

Did you get an answer to your question? Did it help you? The members and moderators here on DUG use our spare time and help you for free, all we ask in return is that you spent a few seconds to let us know if we helped you solve your problem.

If any of the suggestions helped you solve your question/problem, then please click the “Verify Solution” on the answer that helped you, so that we can see that your problem is now “resolved”. Otherwise let us know how if there is something else you like to know.

Have a nice day! [:)]