From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

webservice - upload .net stream

Hi 

I imported several webservice vi, according to webservice document, there is one service, which has a parameter is stream bytes. customer demonstrated the way of using C# to read/convert a file to bytes stream. 

byte[] FileToStream(string fileName)

    {

        // Open file

using (FileStreamfileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))

        {

            // read file byte[] 

byte[] bytes = new byte[fileStream.Length];

fileStream.Read(bytes, 0, bytes.Length);

fileStream.Close();

            // convert byte[] to Stream 

            Stream stream = new MemoryStream(bytes);

byte[] bytes = new byte[stream.Length];

stream.Read(bytes, 0, bytes.Length);

        // set position

stream.Seek(0, SeekOrigin.Begin);

return bytes;

        }

    }

 

My question is how can convert a file (in fact it is a pdf file) to that kind of byte stream which is expected by that webservice?

 

thanks

WD

0 Kudos
Message 1 of 1
(2,490 Views)