示例#1
0
        } // end SendAgentInstanceArchiveToRemoteACIAFServer....

        public void ReceiveAgentInstanceArchiveFROMRemoteACIAFServer(
            RemoteACIAFAgentInstanceArchiveFileInfo request)
        {
            FileStream targetStream = null;
            Stream     sourceStream = request.FileByteStream;

            string uploadFolder = @"d:\toRECEIVE";

            string filePath = Path.Combine(uploadFolder, request.FileName);

            using (targetStream = new FileStream(filePath, FileMode.Create,
                                                 FileAccess.Write, FileShare.None))
            {
                //read from the input stream in 65000 byte chunks

                const int bufferLen = 65000;
                byte[]    buffer    = new byte[bufferLen];
                int       count     = 0;
                while ((count = sourceStream.Read(buffer, 0, bufferLen)) > 0)
                {
                    // save to output stream
                    targetStream.Write(buffer, 0, count);
                    count = 0;
                }
                targetStream.Close();
                sourceStream.Close();
            }
        } //end ReceiveAgentInstanceArchiveFROMRemoteACIAFServer...
示例#2
0
        SendAgentInstanceArchiveToRemoteACIAFServer(DownloadArchivedAgentRequest request)
        {
            RemoteACIAFAgentInstanceArchiveFileInfo result = new RemoteACIAFAgentInstanceArchiveFileInfo();

            try
            {
                string             filePath = System.IO.Path.Combine(@"d:\toSEND\", request.FileName);
                System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath);

                // check if exists
                if (!fileInfo.Exists)
                {
                    throw new System.IO.FileNotFoundException("File not found",
                                                              request.FileName);
                }

                // open stream
                System.IO.FileStream stream = new System.IO.FileStream(filePath,
                                                                       System.IO.FileMode.Open, System.IO.FileAccess.Read);

                // return result
                result.FileName       = request.FileName;
                result.Length         = fileInfo.Length;
                result.FileByteStream = stream;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(result);
        } // end SendAgentInstanceArchiveToRemoteACIAFServer....