public void RetrieveFile(string filePath, string dirToSaveTo, bool IsBitMap)
        {
            Stream       inputStream       = null;
            FileStream   writeStream       = null;
            MemoryStream writeBitMapStream = null;
            const int    chunkSize         = 1048576;
            int          bytesRead         = 0;
            long         downloadedLength  = 0;

            byte[] buffer = new byte[chunkSize];


            FileData fileData = new FileData();

            fileData.FileNameFullPath = filePath;
            fileData.DirectoryName    = Path.GetDirectoryName(filePath);

            fileData.FileName = Path.GetFileName(filePath);

            string saveToFile = dirToSaveTo + fileData.FileName;

            ResponseFileDetails retVal = _proxySubStreaming.UploadFileDataName(fileData);

            long length = retVal.Length;

            inputStream = retVal.FileByteStream;

            if (IsBitMap)
            {
                writeBitMapStream = new MemoryStream();
                while (length != downloadedLength)
                {
                    bytesRead = inputStream.Read(buffer, 0, chunkSize);
                    writeBitMapStream.Write(buffer, 0, bytesRead);

                    downloadedLength += bytesRead;
                }
                using (Image image = Image.FromStream(writeBitMapStream))
                {
                    // Upon success image contains the bitmap
                    //  and can be saved to a file:
                    image.Save(saveToFile);
                }
                writeBitMapStream.Close();
            }
            else
            {
                writeStream = new FileStream(saveToFile, System.IO.FileMode.Append, System.IO.FileAccess.Write);
                while (length != downloadedLength)
                {
                    bytesRead = inputStream.Read(buffer, 0, chunkSize);
                    writeStream.Write(buffer, 0, bytesRead);
                    downloadedLength += bytesRead;
                }
                writeStream.Close();
            }
        }