Ejemplo n.º 1
0
        private byte[] GetFile(IFileTransfer host, string fileName)
        {
            RemoteFileInfo fileInfo = new RemoteFileInfo();

            byte[] file = new byte[0];

            try
            {
                DownloadRequest requestData = new DownloadRequest();

                requestData.FileName = fileName;

                fileInfo = host.DownloadFile(requestData);

                using (MemoryStream stream = new MemoryStream())
                {
                    fileInfo.FileByteStream.CopyTo(stream);
                    file = stream.ToArray();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex.Message);
            }
            finally
            {
                fileInfo.FileByteStream.Close();
            }

            return file;
        }