File to Byte Conversion – Client to Server Move

Hey Friends,

This is a very simple post on how to move a file from your client computer to server computer. We all are well equipped and experienced in moving a file directly from a physical path, if we simply need to just copy that file as we all have expertise in using File Management Codeunit.  I just experienced a case where client was scanning the file from NAV and then and there he requested that the scanned file can anyhow directly move into server computer without any physical storage in the current client machine.

As the scanning form was a part of .NET dll so to achieve this and after scanning I sent that scanned file as a parameter in Big-text format to NAV Web Service. Here the actual work comes into play. Look at the below piece of code

//RWN
Byte:=Convert.FromBase64String(FileInBigText); FileInBigText includes scanned file
MemoryStream:=MemoryStream.MemoryStream(Byte);
TempBlob.DELETEALL;
TempBlob.INIT;
TempBlob.Blob.CREATEOUTSTREAM(OutStream);
MemoryStream.WriteTo(OutStream);
TempBlob.INSERT;

File.CREATE(FilePath); Filepath Includes Path + Name + FileType
File.CREATEOUTSTREAM(FileOutStream);
TempBlob.Blob.CREATEINSTREAM(FileInStream);
COPYSTREAM(FileOutStrm,FileInStream);
File.CLOSE;
//RWN

CHEERS

2 comments on “File to Byte Conversion – Client to Server Move

  1. Pingback: File to Byte Conversion – Client to Server Move - Microsoft Dynamics NAV Community

  2. Pingback: File to Byte Conversion – Client to Server Move - Dynamics NAV by RockWithNAV - Dynamics NAV Users - DUG

Leave a comment