Example #1
0
 void download(string filename)
 {
     try
     {
         Stream strm      = channel.downLoadFile(filename);
         string rfilename = Path.Combine(SavePath, filename);
         if (!Directory.Exists(SavePath))
         {
             Directory.CreateDirectory(SavePath);
         }
         using (var outputStream = new FileStream(rfilename, FileMode.Create))
         {
             while (true)
             {
                 int bytesRead = strm.Read(block, 0, BlockSize);
                 if (bytesRead > 0)
                 {
                     outputStream.Write(block, 0, bytesRead);
                 }
                 else
                 {
                     break;
                 }
             }
         }
         Console.Write("\n  Received file \"{0}\"", filename);
     }
     catch (Exception ex)
     {
         Console.Write("\n  {0}\n", ex.Message);
     }
 }
        void download(string filename)
        {
            int BlockSize = 1024;

            byte[]     block      = new byte[BlockSize];
            string     SavePath   = "..\\..\\..\\Client_1\\Logs";
            int        totalBytes = 0;
            HiResTimer hrt        = new HiResTimer();

            try
            {
                hrt.Start();
                Stream strm      = channel.downLoadFile(filename);
                string rfilename = System.IO.Path.Combine(SavePath, filename);
                if (!Directory.Exists(SavePath))
                {
                    Directory.CreateDirectory(SavePath);
                }
                using (var outputStream = new FileStream(rfilename, FileMode.Create))
                {
                    while (true)
                    {
                        int bytesRead = strm.Read(block, 0, BlockSize);
                        totalBytes += bytesRead;
                        if (bytesRead > 0)
                        {
                            outputStream.Write(block, 0, bytesRead);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                hrt.Stop();
                ulong time = hrt.ElapsedMicroseconds;
                Console.Write("\n  Received file \"{0}\" of {1} bytes in {2} microsec.", filename, totalBytes, time);
            }
            catch (Exception ex)
            {
                Console.Write("\n  {0}", ex.Message);
            }
        }
Example #3
0
        void download(string filename, string savePath)
        {
            //string savePath = "..\\..\\..\\Repository\\RepositoryStorage"
            int BlockSize = 1024;

            byte[]     block;
            HiResTimer hrt2 = new HiResTimer();

            block = new byte[BlockSize];
            int totalBytes = 0;

            hrt2.Start();
            Stream strm      = channel.downLoadFile(filename);
            string rfilename = Path.Combine(savePath, filename);

            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }
            using (var outputStream = new FileStream(rfilename, FileMode.Create))
            {
                while (true)
                {
                    int bytesRead = strm.Read(block, 0, BlockSize);
                    totalBytes += bytesRead;
                    if (bytesRead > 0)
                    {
                        outputStream.Write(block, 0, bytesRead);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            hrt2.Stop();
            ulong time = hrt2.ElapsedMicroseconds;

            Console.Write("\n  Received file \"{0}\" of {1} bytes in {2} microsec.", filename, totalBytes, time);
        }
        void ClientDownload(string filename)
        {
            int totalBytes = 0;

            hrt.Start();
            try
            {
                Stream strm      = fileProxy.downLoadFile(filename);
                string rfilename = System.IO.Path.Combine(SavePath, filename);
                if (!Directory.Exists(SavePath))
                {
                    Directory.CreateDirectory(SavePath);
                }
                using (var outputStream = new FileStream(rfilename, FileMode.Create))
                {
                    while (true)
                    {
                        int bytesRead = strm.Read(block, 0, BlockSize);
                        totalBytes += bytesRead;
                        if (bytesRead > 0)
                        {
                            outputStream.Write(block, 0, bytesRead);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                hrt.Stop();
                ulong time = hrt.ElapsedMicroseconds;
                Console.Write("\n  Received file \"{0}\" of {1} bytes in {2} microsec.", filename, totalBytes, time);
            }
            catch (Exception ex)
            {
                Console.Write("\n  {0}\n", ex.Message);
            }
        }
Example #5
0
        public void download(string filename)
        {
            int totalBytes = 0;

            try
            {
                hrt.Start();
                Stream strm      = channel.downLoadFile(filename);
                string rfilename = Path.Combine(SavePath, filename);
                if (!Directory.Exists(SavePath))
                {
                    Directory.CreateDirectory(SavePath);
                }
                using (var outputStream = new FileStream(rfilename, FileMode.Create))
                {
                    while (true)
                    {
                        int bytesRead = strm.Read(block, 0, BlockSize);
                        totalBytes += bytesRead;
                        if (bytesRead > 0)
                        {
                            outputStream.Write(block, 0, bytesRead);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                hrt.Stop();
                ulong time = hrt.ElapsedMicroseconds;
                Console.Write("\n  Received file \"{0}\" of {1} bytes in {2} microsec.", filename, totalBytes, time);
            }
            catch
            {
                Console.Write("\n The file isn't available in the repository");
            }
        }