System.IO.Stream.Flush()

Here are the examples of the csharp api System.IO.Stream.Flush() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

836 Examples 7

19 View Source File : MeshSaver.cs
License : MIT License
Project Creator : anderm

public static string Save(string fileName, IEnumerable<MeshFilter> meshFilters)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("Must specify a valid fileName.");
            }

            if (meshFilters == null)
            {
                throw new ArgumentNullException("Value of meshFilters cannot be null.");
            }

            // Create the mesh file.
            String folderName = MeshFolderName;
            Debug.Log(String.Format("Saving mesh file: {0}", Path.Combine(folderName, fileName + fileExtension)));

            using (Stream stream = OpenFileForWrite(folderName, fileName + fileExtension))
            {
                // Serialize and write the meshes to the file.
                byte[] data = SimpleMeshSerializer.Serialize(meshFilters);
                stream.Write(data, 0, data.Length);
                stream.Flush();
            }

            Debug.Log("Mesh file saved.");

            return Path.Combine(folderName, fileName + fileExtension);
        }

19 View Source File : InflaterInputStream.cs
License : GNU General Public License v3.0
Project Creator : anydream

public override void Flush()
		{
			baseInputStream.Flush();
		}

19 View Source File : ArduinoReceive_ Section 6.cs
License : GNU General Public License v3.0
Project Creator : AlexandreDoucet

private void WriteToArduino(string message)
	{
		if (arduinoPort.IsOpen) 
		{	
			message = message + "\r\n";
			arduinoPort.Write (message);
			arduinoPort.BaseStream.Flush ();
		}	 
		else 
		{	
			Debug.Log ("PortNotOpen");
		}	
	}

19 View Source File : HTTPChallengeWebServerValidator.cs
License : GNU General Public License v3.0
Project Creator : aloopkin

private void Process(HttpListenerContext context)
        {
            logger.Debug($"Processing the serving of content: {_tokenContents}");
            byte[] buf = Encoding.UTF8.GetBytes(_tokenContents);
            // First the headers
            context.Response.ContentType = "application/octet-stream";
            context.Response.ContentLength64 = buf.Length;
            context.Response.AddHeader("Date", DateTime.Now.ToString("r"));
            context.Response.StatusCode = 200;

            // Then the contents...erm, always the same !
            context.Response.OutputStream.Write(buf, 0, buf.Length);

            // We flush and close
            context.Response.OutputStream.Flush();
            context.Response.OutputStream.Close();
        }

19 View Source File : ProgressStream.cs
License : MIT License
Project Creator : alexis-

public override void Flush()
    {
      innerStream.Flush();
    }

19 View Source File : ResponseExtension.cs
License : GNU General Public License v3.0
Project Creator : aiportal

private static void WriteFileContent(HttpListenerResponse resp, byte[] data, string mime, bool compress)
		{
			if (compress)
			{
				resp.Headers[HttpResponseHeader.ContentEncoding] = "gzip";
				data = Compress.GZip(data, true);
			}

			resp.ContentType = mime;
			resp.ContentEncoding = Encoding.UTF8;

			SetDebugMode(resp);
			resp.OutputStream.Write(data, 0, data.Length);
			resp.OutputStream.Flush();
			resp.Close();
		}

19 View Source File : WrappingStream.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : anoyetta

public override void Flush() => this.m_streamBase?.Flush();

19 View Source File : Stream.cs
License : Mozilla Public License 2.0
Project Creator : ahyahy

public virtual void Flush()
        {
            M_Stream.Flush();
        }

19 View Source File : ZipHelperStream.cs
License : GNU General Public License v3.0
Project Creator : anydream

public override void Flush()
		{
			stream_.Flush();
		}

19 View Source File : HttpResponse.cs
License : GNU General Public License v3.0
Project Creator : aiportal

public void SendErrorPage(int errCode, string errMsg)
		{
			Debug.replacedert(errCode > 0);

			byte[] bsMsg = Encoding.UTF8.GetBytes(errMsg);
			Response.StatusCode = errCode;
			Response.StatusDescription = errMsg;

			SetExpires(0);
			Response.ContentType = "text/plain";
			Response.ContentEncoding = Encoding.UTF8;

			SetDebugHeaders();
			Response.OutputStream.Write(bsMsg, 0, bsMsg.Length);
			Response.OutputStream.Flush();
			Response.Close();
		}

19 View Source File : ThriftStream.cs
License : MIT License
Project Creator : aloneguid

public int Write<T>(T obj, bool rewind = false) where T : TBase, new()
      {
         _s.Flush();
         long startPos = _s.Position;
         obj.Write(_protocol);
         _s.Flush();
         long size = _s.Position - startPos;
         if (rewind) _s.Seek(startPos, SeekOrigin.Begin);
         return (int)size;
      }

19 View Source File : AlipayMobilePublicMultiMediaClient.cs
License : Apache License 2.0
Project Creator : alipay

public void GetResponsereplacedtream(Stream outStream, HttpWebResponse rsp)
        {
            StringBuilder result = new StringBuilder();
            Stream stream = null;
            StreamReader reader = null;
            BinaryWriter writer = null;

            try
            {
                // 以字符流的方式读取HTTP响应
                stream = rsp.GetResponseStream();
                reader = new StreamReader(stream);

                writer = new BinaryWriter(outStream);

                //stream.CopyTo(outStream);
                int length = Convert.ToInt32(rsp.ContentLength);
                byte[] buffer = new byte[length];
                int rc = 0;
                while ((rc = stream.Read(buffer, 0, length)) > 0)
                {
                    outStream.Write(buffer, 0, rc);
                }
                outStream.Flush();
                outStream.Close();

            }
            finally
            {
                // 释放资源
                if (reader != null) reader.Close();
                if (stream != null) stream.Close();
                if (rsp != null) rsp.Close();
            }
        }

19 View Source File : HttpResponse.cs
License : GNU General Public License v3.0
Project Creator : aiportal

public void SendJsonScript(string script, bool compress = true, bool expires = false)
		{
			byte[] bsJson = Encoding.UTF8.GetBytes(script);
			if (compress)
			{
				Response.Headers[HttpResponseHeader.ContentEncoding] = "gzip";
				bsJson = bfbd.Common.Compress.GZip(bsJson, true);
			}

			SetExpires(expires ? 0 : 600);
			Response.ContentType = "text/plain";
			Response.ContentEncoding = Encoding.UTF8;
			
			SetDebugHeaders();
			Response.OutputStream.Write(bsJson, 0, bsJson.Length);
			Response.OutputStream.Flush();
			Response.Close();
		}

19 View Source File : DataMockSI.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn

public async Task<DataElement> InsertBinaryData(string instanceId, string dataType, string contentType, string filename, Stream stream)
        {
            Application app = _applicationService.GetApplication();

            Guid dataGuid = Guid.NewGuid();
            string dataPath = GetDataPath(app.Org, app.Id.Split("/")[1], Convert.ToInt32(instanceId.Split("/")[0]), new Guid(instanceId.Split("/")[1]));

            DataElement dataElement = new DataElement() { Id = dataGuid.ToString(), DataType = dataType, ContentType = contentType, };

            if (!Directory.Exists(Path.GetDirectoryName(dataPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(dataPath));
            }

            Directory.CreateDirectory(dataPath + @"blob");

            long filesize;

            using (Stream streamToWriteTo = File.Open(dataPath + @"blob\" + dataGuid.ToString(), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                await stream.CopyToAsync(streamToWriteTo);
                streamToWriteTo.Flush();
                filesize = streamToWriteTo.Length;
            }

            dataElement.Size = filesize;
            string jsonData = JsonConvert.SerializeObject(dataElement);
            using StreamWriter sw = new StreamWriter(dataPath + dataGuid.ToString() + @".json");

            sw.Write(jsonData.ToString());
            sw.Close();

            return dataElement;
        }

19 View Source File : FileLoggerProcessor.cs
License : MIT License
Project Creator : adams85

internal void Flush()
            {
                // FlushAsync is extremely slow currently
                // https://github.com/dotnet/corefx/issues/32837
                _appendStream.Flush();
            }

19 View Source File : PayServices.cs
License : Apache License 2.0
Project Creator : anjoy8

public async Task<MessageModel<PayRefundReturnResultModel>> PayRefund(PayRefundNeedModel payModel)
        {
            _logger.LogInformation("退款开始");
            MessageModel<PayRefundReturnResultModel> messageModel = new MessageModel<PayRefundReturnResultModel>();
            messageModel.response = new PayRefundReturnResultModel();
            try
            {
                _logger.LogInformation($"原始GET参数->{_httpContextAccessor.HttpContext.Request.QueryString}");

                string REQUEST_SN = StringHelper.GetGuidToLongID().ToString().Substring(0, 16);//请求序列码
                string CUST_ID = StaticPayInfo.MERCHANTID;//商户号
                string USER_ID = StaticPayInfo.USER_ID;//操作员号
                string PreplacedWORD = StaticPayInfo.PreplacedWORD;//密码
                string TX_CODE = "5W1004";//交易码
                string LANGUAGE = "CN";//语言
                                       //string SIGN_INFO = "";//签名信息
                                       //string SIGNCERT = "";//签名CA信息
                                       //外联平台客户端服务部署的地址+设置的监听端口
                string sUrl = StaticPayInfo.OutAddress;

                //XML请求报文
                //string sRequestMsg = $" requestXml=<?xml version=\"1.0\" encoding=\"GB2312\" standalone=\"yes\" ?><TX><REQUEST_SN>{REQUEST_SN}</REQUEST_SN><CUST_ID>{CUST_ID}</CUST_ID><USER_ID>{USER_ID}</USER_ID><PreplacedWORD>{PreplacedWORD}</PreplacedWORD><TX_CODE>{TX_CODE}</TX_CODE><LANGUAGE>{LANGUAGE}</LANGUAGE><TX_INFO><MONEY>{payModel.MONEY}</MONEY><ORDER>{payModel.ORDER}</ORDER><REFUND_CODE>{payModel.REFUND_CODE}</REFUND_CODE></TX_INFO><SIGN_INFO></SIGN_INFO><SIGNCERT></SIGNCERT></TX> ";
                string sRequestMsg = $"<?xml version=\"1.0\" encoding=\"GB2312\" standalone=\"yes\" ?><TX><REQUEST_SN>{REQUEST_SN}</REQUEST_SN><CUST_ID>{CUST_ID}</CUST_ID><USER_ID>{USER_ID}</USER_ID><PreplacedWORD>{PreplacedWORD}</PreplacedWORD><TX_CODE>{TX_CODE}</TX_CODE><LANGUAGE>{LANGUAGE}</LANGUAGE><TX_INFO><MONEY>{payModel.MONEY}</MONEY><ORDER>{payModel.ORDER}</ORDER><REFUND_CODE>{payModel.REFUND_CODE}</REFUND_CODE></TX_INFO><SIGN_INFO></SIGN_INFO><SIGNCERT></SIGNCERT></TX> ";

                //string sRequestMsg = readRequestFile("E:/02-外联平台/06-测试/测试报文/商户网银/客户端连接-5W1001-W06.txt");


                //注意:请求报文必须放在requestXml参数送
                sRequestMsg = "requestXml=" + sRequestMsg;

                _logger.LogInformation("请求地址:" + sUrl);
                _logger.LogInformation("请求报文:" + sRequestMsg);
                HttpWebRequest request = (System.Net.HttpWebRequest)HttpWebRequest.Create(sUrl);
                request.Method = "POST";

                request.ContentType = "application/x-www-form-urlencoded";
                request.KeepAlive = false;
                request.Connection = "";

                //外联平台使用GB18030编码,这里进行转码处理 
                byte[] byteRquest = Encoding.GetEncoding("GB18030").GetBytes(sRequestMsg);
                request.ContentLength = byteRquest.Length;

                //发送请求
                Stream writerStream = request.GetRequestStream();
                await writerStream.WriteAsync(byteRquest, 0, byteRquest.Length);
                writerStream.Flush();
                writerStream.Close();

                //接收请求
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream result = response.GetResponseStream();
                StreamReader readerResult = new StreamReader(result, System.Text.Encoding.GetEncoding("GB18030"));
                string sResult = await readerResult.ReadToEndAsync();
                _logger.LogInformation("响应报文:" + sResult);
                var Xmlresult = XmlHelper.ParseFormByXml<PayRefundReturnModel>(sResult, "TX");
                if (Xmlresult.RETURN_CODE.Equals("000000"))
                {
                    messageModel.success = true;
                    messageModel.msg = "退款成功";
                }
                else
                {
                    messageModel.success = false;
                    messageModel.msg = "退款失败";
                }
                messageModel.response.RETURN_MSG = Xmlresult.RETURN_MSG;
                messageModel.response.TX_CODE = Xmlresult.TX_CODE;
                messageModel.response.REQUEST_SN = Xmlresult.REQUEST_SN;
                messageModel.response.RETURN_CODE = Xmlresult.RETURN_CODE;
                messageModel.response.CUST_ID = Xmlresult.CUST_ID;
                messageModel.response.LANGUAGE = Xmlresult.LANGUAGE;

                messageModel.response.AMOUNT = Xmlresult.TX_INFO?.AMOUNT;
                messageModel.response.PAY_AMOUNT = Xmlresult.TX_INFO?.PAY_AMOUNT;
                messageModel.response.ORDER_NUM = Xmlresult.TX_INFO?.ORDER_NUM;
            }
            catch (Exception ex)
            {
                messageModel.success = false;
                messageModel.msg = "服务错误";
                messageModel.response.RETURN_MSG = ex.Message;
                _logger.LogInformation($"异常信息:{ex.Message}");
                _logger.LogInformation($"异常堆栈:{ex.StackTrace}");
            }
            finally
            {
                _logger.LogInformation($"返回数据->{JsonHelper.GetJSON<MessageModel<PayRefundReturnResultModel>>(messageModel)}");
                _logger.LogInformation("退款结束");
            }
            return messageModel;

        }

19 View Source File : ArduinoInfo.cs
License : GNU General Public License v3.0
Project Creator : AlexandreDoucet

public void WriteToArduino(string message)
    {
        if (arduinoPort.IsOpen)
        {
            message = message + "\r\n";
            arduinoPort.Write(message);
            arduinoPort.BaseStream.Flush();
        }
    }

19 View Source File : DeflaterOutputStream.cs
License : GNU General Public License v3.0
Project Creator : anydream

public virtual void Finish()
		{
			deflater_.Finish();
			while (!deflater_.IsFinished) {
				int len = deflater_.Deflate(buffer_, 0, buffer_.Length);
				if (len <= 0) {
					break;
				}

				if (cryptoTransform_ != null) {
					EncryptBlock(buffer_, 0, len);
				}

				baseOutputStream_.Write(buffer_, 0, len);
			}

			if (!deflater_.IsFinished) {
				throw new SharpZipBaseException("Can't deflate all input?");
			}

			baseOutputStream_.Flush();

			if (cryptoTransform_ != null) {
				if (cryptoTransform_ is ZipAESTransform) {
					AESAuthCode = ((ZipAESTransform)cryptoTransform_).GetAuthCode();
				}
				cryptoTransform_.Dispose();
				cryptoTransform_ = null;
			}
		}

19 View Source File : RangeCoder.cs
License : MIT License
Project Creator : 91Act

public void FlushStream()
		{
			Stream.Flush();
		}

19 View Source File : StreamUtils.cs
License : GNU General Public License v3.0
Project Creator : anydream

static public void Copy(Stream source, Stream destination,
			byte[] buffer,
			ProgressHandler progressHandler, TimeSpan updateInterval,
			object sender, string name, long fixedTarget)
		{
			if (source == null) {
				throw new ArgumentNullException(nameof(source));
			}

			if (destination == null) {
				throw new ArgumentNullException(nameof(destination));
			}

			if (buffer == null) {
				throw new ArgumentNullException(nameof(buffer));
			}

			// Ensure a reasonable size of buffer is used without being prohibitive.
			if (buffer.Length < 128) {
				throw new ArgumentException("Buffer is too small", nameof(buffer));
			}

			if (progressHandler == null) {
				throw new ArgumentNullException(nameof(progressHandler));
			}

			bool copying = true;

			DateTime marker = DateTime.Now;
			long processed = 0;
			long target = 0;

			if (fixedTarget >= 0) {
				target = fixedTarget;
			} else if (source.CanSeek) {
				target = source.Length - source.Position;
			}

			// Always fire 0% progress..
			var args = new ProgressEventArgs(name, processed, target);
			progressHandler(sender, args);

			bool progressFired = true;

			while (copying) {
				int bytesRead = source.Read(buffer, 0, buffer.Length);
				if (bytesRead > 0) {
					processed += bytesRead;
					progressFired = false;
					destination.Write(buffer, 0, bytesRead);
				} else {
					destination.Flush();
					copying = false;
				}

				if (DateTime.Now - marker > updateInterval) {
					progressFired = true;
					marker = DateTime.Now;
					args = new ProgressEventArgs(name, processed, target);
					progressHandler(sender, args);

					copying = args.ContinueRunning;
				}
			}

			if (!progressFired) {
				args = new ProgressEventArgs(name, processed, target);
				progressHandler(sender, args);
			}
		}

19 View Source File : HttpServer.cs
License : MIT License
Project Creator : AlexGyver

private void ServeResourceFile(HttpListenerResponse response, string name, 
      string ext) 
    {
      // resource names do not support the hyphen
      name = "OpenHardwareMonitor.Resources." + 
        name.Replace("custom-theme", "custom_theme");

      string[] names =
        replacedembly.GetExecutingreplacedembly().GetManifestResourceNames();
      for (int i = 0; i < names.Length; i++) {
        if (names[i].Replace('\\', '.') == name) {
          using (Stream stream = replacedembly.GetExecutingreplacedembly().
            GetManifestResourceStream(names[i])) {
            response.ContentType = GetcontentType("." + ext);
            response.ContentLength64 = stream.Length;
            byte[] buffer = new byte[512 * 1024];
            int len;
            try {
              Stream output = response.OutputStream;
              while ((len = stream.Read(buffer, 0, buffer.Length)) > 0) {
                output.Write(buffer, 0, len);
              }
              output.Flush();
              output.Close();              
              response.Close();
            } catch (HttpListenerException) { 
            } catch (InvalidOperationException) { 
            }
            return;
          }          
        }
      }

      response.StatusCode = 404;
      response.Close();
    }

19 View Source File : PngEncoder.cs
License : MIT License
Project Creator : AlexGyver

public byte[] ToArray()
            {
                this.BaseStream.Flush();
                return ((MemoryStream)this.BaseStream).ToArray();
            }

19 View Source File : OutBuffer.cs
License : MIT License
Project Creator : 91Act

public void FlushStream() { m_Stream.Flush(); }

19 View Source File : ProgressStreamContent.cs
License : MIT License
Project Creator : alexrainman

public override void Flush()
            {
                ParentStream.Flush();
            }

19 View Source File : HttpResponse.cs
License : GNU General Public License v3.0
Project Creator : aiportal

public void SendException(Exception ex)
		{
			byte[] bsException = Encoding.UTF8.GetBytes(ex.ToString());

			SetExpires(0);
			Response.ContentType = "text/plain";
			Response.ContentEncoding = Encoding.UTF8;

			SetDebugHeaders();
			Response.OutputStream.Write(bsException, 0, bsException.Length);
			Response.OutputStream.Flush();
		}

19 View Source File : GapStream.cs
License : MIT License
Project Creator : aloneguid

public override void Flush()
      {
         _parent.Flush();
      }

19 View Source File : TStreamTransport.cs
License : MIT License
Project Creator : aloneguid

public override void Flush()
        {
            if (outputStream == null)
            {
                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot flush null outputstream");
            }

            outputStream.Flush();
        }

19 View Source File : HttpResponse.cs
License : GNU General Public License v3.0
Project Creator : aiportal

public void SendJsonError(int errCode, string errMsg)
		{
			byte[] bsMsg = Encoding.UTF8.GetBytes(errMsg);

			SetExpires(0);
			Response.ContentType = "text/plain";
			Response.ContentEncoding = Encoding.UTF8;

			SetDebugHeaders();
			Response.OutputStream.Write(bsMsg, 0, bsMsg.Length);
			Response.OutputStream.Flush();
			Response.Close();
		}

19 View Source File : ParquetWriter.cs
License : MIT License
Project Creator : aloneguid

public void Dispose()
#pragma warning restore CA1063 // Implement IDisposable Correctly
      {
         if (_dataWritten)
         {
            //update row count (on append add row count to existing metadata)
            _footer.Add(_openedWriters.Sum(w => w.RowCount ?? 0));
         }

         //finalize file
         long size = _footer.Write(ThriftStream);

         //metadata size
         Writer.Write((int)size);  //4 bytes

         //end magic
         WriteMagic();              //4 bytes

         Writer.Flush();
         Stream.Flush();
      }

19 View Source File : Host.cs
License : MIT License
Project Creator : acandylevey

public void SendMessage(JObject data)
        {
            Log.LogMessage("Sending Message:" + JsonConvert.SerializeObject(data));

            byte[] bytes = System.Text.Encoding.UTF8.GetBytes(data.ToString(Formatting.None));
            Stream stdout = Console.OpenStandardOutput();
            stdout.WriteByte((byte)((bytes.Length >> 0) & 0xFF));
            stdout.WriteByte((byte)((bytes.Length >> 8) & 0xFF));
            stdout.WriteByte((byte)((bytes.Length >> 16) & 0xFF));
            stdout.WriteByte((byte)((bytes.Length >> 24) & 0xFF));
            stdout.Write(bytes, 0, bytes.Length);
            stdout.Flush();
        }

19 View Source File : DataMockSI.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn

public async Task<DataElement> InsertBinaryData(string org, string app, int instanceOwnerId, Guid instanceGuid, string dataType, HttpRequest request)
        {
            Guid dataGuid = Guid.NewGuid();
            string dataPath = GetDataPath(org, app, instanceOwnerId, instanceGuid);
            Instance instance = GetTestInstance(app, org, instanceOwnerId, instanceGuid);
            DataElement dataElement = new DataElement() { Id = dataGuid.ToString(), DataType = dataType, ContentType = request.ContentType };

            if (!Directory.Exists(Path.GetDirectoryName(dataPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(dataPath));
            }

            Directory.CreateDirectory(dataPath + @"blob");

            long filesize;

            using (Stream streamToWriteTo = File.Open(dataPath + @"blob\" + dataGuid.ToString(), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                await request.Body.CopyToAsync(streamToWriteTo);
                streamToWriteTo.Flush();
                filesize = streamToWriteTo.Length;
                streamToWriteTo.Close();
            }

            dataElement.Size = filesize;
            string jsonData = JsonConvert.SerializeObject(dataElement);
            using StreamWriter sw = new StreamWriter(dataPath + dataGuid.ToString() + @".json");

            sw.Write(jsonData.ToString());
            sw.Close();

            return dataElement;
        }

19 View Source File : HttpResponse.cs
License : GNU General Public License v3.0
Project Creator : aiportal

public void SendImage(byte[] bsImage, string fileExtension)
		{
			SetExpires(600);
			Response.ContentType = ApacheMimeTypes.Get(fileExtension);
			Response.ContentEncoding = Encoding.UTF8;
			
			SetDebugHeaders();
			Response.OutputStream.Write(bsImage, 0, bsImage.Length);
			Response.OutputStream.Flush();
			Response.Close();
		}

19 View Source File : PolicyRepositoryMock.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn

private async Task<Response<BlobContentInfo>> WriteStreamToTestDataFolder(string filepath, Stream fileStream)
        {
            string dataPath = GetDataBlobPath() + filepath;

            if (!Directory.Exists(Path.GetDirectoryName(dataPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(dataPath));
            }

            int filesize;

            using (Stream streamToWriteTo = File.Open(dataPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                await fileStream.CopyToAsync(streamToWriteTo);
                streamToWriteTo.Flush();
                filesize = (int)streamToWriteTo.Length;
            }

            BlobContentInfo mockedBlobInfo = BlobsModelFactory.BlobContentInfo(new ETag("ETagSuccess"), DateTime.Now, new byte[1], DateTime.Now.ToUniversalTime().ToString(), "encryptionKeySha256", "encryptionScope", 1);
            Mock<Response<BlobContentInfo>> mockResponse = new Mock<Response<BlobContentInfo>>();
            mockResponse.SetupGet(r => r.Value).Returns(mockedBlobInfo);

            Mock<Response> responseMock = new Mock<Response>();
            responseMock.SetupGet(r => r.Status).Returns((int)HttpStatusCode.Created);
            mockResponse.Setup(r => r.GetRawResponse()).Returns(responseMock.Object);

            return mockResponse.Object;
        }

19 View Source File : RedisIO.cs
License : MIT License
Project Creator : 2881099

public void Write(Stream stream)
        {
            lock (_streamLock)
            {
                stream.CopyTo(Stream);
                Stream.Flush();
            }
        }

19 View Source File : MeshSaver.cs
License : MIT License
Project Creator : anderm

public static string Save(string fileName, IEnumerable<Mesh> meshes)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("Must specify a valid fileName.");
            }

            if (meshes == null)
            {
                throw new ArgumentNullException("Value of meshes cannot be null.");
            }

            // Create the mesh file.
            String folderName = MeshFolderName;
            Debug.Log(String.Format("Saving mesh file: {0}", Path.Combine(folderName, fileName + fileExtension)));

            using (Stream stream = OpenFileForWrite(folderName, fileName + fileExtension))
            {
                // Serialize and write the meshes to the file.
                byte[] data = SimpleMeshSerializer.Serialize(meshes);
                stream.Write(data, 0, data.Length);
                stream.Flush();
            }

            Debug.Log("Mesh file saved.");

            return Path.Combine(folderName, fileName + fileExtension);
        }

19 View Source File : TweakableStream.cs
License : MIT License
Project Creator : airbreather

public override void Flush() => _inner.Flush();

19 View Source File : ClippedStream.cs
License : GNU General Public License v3.0
Project Creator : anotak

public override void Flush()
		{
			// Flush base stream
			basestream.Flush();
		}

19 View Source File : IOHelper.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public static bool XMLSerializer<T>(Stream ms, T args)
        {
            if (Equals(args, default(T)))
                return false;
            ms.SetLength(1);
            var ds = new DataContractSerializer(typeof(T));
            ds.WriteObject(ms, args);
            ms.Flush();
            return true;
        }

19 View Source File : StreamIStream.cs
License : GNU General Public License v3.0
Project Creator : anydream

public void Commit(int grfCommitFlags) {
			stream.Flush();
		}

19 View Source File : ArduinoInfo.cs
License : GNU General Public License v3.0
Project Creator : AlexandreDoucet

public void ArduinoAgentCleanup()
    {
        try
        {
            if (arduinoPort.IsOpen)
            {
                WriteToArduino("DONE");
                arduinoPort.BaseStream.Flush();
                arduinoPort.Dispose();
            }
        }
        catch/* (System.NullReferenceException e)*/
        {
            //    Debug.LogWarning("Handled Error -> " + e.GetType() + " : " + e.Message);
        }


    }

19 View Source File : DeflaterOutputStream.cs
License : GNU General Public License v3.0
Project Creator : anydream

public override void Flush()
		{
			deflater_.Flush();
			Deflate();
			baseOutputStream_.Flush();
		}

19 View Source File : PositionAwareStream.cs
License : MIT License
Project Creator : 0x0ade

public override void Flush() {
            Inner.Flush();
        }

19 View Source File : StreamUtils.cs
License : GNU General Public License v3.0
Project Creator : anydream

static public void Copy(Stream source, Stream destination, byte[] buffer)
		{
			if (source == null) {
				throw new ArgumentNullException(nameof(source));
			}

			if (destination == null) {
				throw new ArgumentNullException(nameof(destination));
			}

			if (buffer == null) {
				throw new ArgumentNullException(nameof(buffer));
			}

			// Ensure a reasonable size of buffer is used without being prohibitive.
			if (buffer.Length < 128) {
				throw new ArgumentException("Buffer is too small", nameof(buffer));
			}

			bool copying = true;

			while (copying) {
				int bytesRead = source.Read(buffer, 0, buffer.Length);
				if (bytesRead > 0) {
					destination.Write(buffer, 0, bytesRead);
				} else {
					destination.Flush();
					copying = false;
				}
			}
		}

19 View Source File : ArduinoReveive_Section 5.cs
License : GNU General Public License v3.0
Project Creator : AlexandreDoucet

private void WriteToArduino(string message)
    {
        if (arduinoPort.IsOpen)
        {
            message = message + "\r\n";
            arduinoPort.Write(message);
            arduinoPort.BaseStream.Flush();
        }
        else
        {
            Debug.Log("PortNotOpen");
        }
    }

19 View Source File : HttpResponse.cs
License : GNU General Public License v3.0
Project Creator : aiportal

public void SendStaticFile(string fpath, byte[] bsFile)
		{
			Debug.replacedert(!string.IsNullOrEmpty(fpath));
			Debug.replacedert(bsFile != null && bsFile.Length > 0);
			
			SetExpires(0);
			Response.ContentType = ApacheMimeTypes.Get(Path.GetExtension(fpath));
			Response.ContentEncoding = Encoding.UTF8;
			
			SetDebugHeaders();
			if (Response.OutputStream.CanWrite)
			{
				Response.OutputStream.Write(bsFile, 0, bsFile.Length);
				Response.OutputStream.Flush();
			}
			//Response.Close();
		}

19 View Source File : DisposeActionStream.cs
License : MIT License
Project Creator : 0x0ade

public override void Flush() => Inner.Flush();

19 View Source File : RedisIO.cs
License : MIT License
Project Creator : 2881099

public void Write(byte[] data)
        {
            lock (_streamLock)
            {
                Stream.Write(data, 0, data.Length);
                Stream.Flush();
            }
        }

19 View Source File : DateAndSizeRollingFileAppender.cs
License : MIT License
Project Creator : Abc-Arbitrage

public override void Flush()
            => _stream?.Flush();

19 View Source File : HttpResponse.cs
License : GNU General Public License v3.0
Project Creator : aiportal

public void SendJsonObject(object result, bool compress = true)
		{
			// json serialize
			byte[] bsJson = Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(result));
			if (compress)
			{
				Response.Headers[HttpResponseHeader.ContentEncoding] = "gzip";
				bsJson = bfbd.Common.Compress.GZip(bsJson, true);
			}

			SetExpires(0);
			Response.ContentType = "text/json";
			Response.ContentEncoding = Encoding.UTF8;

			SetDebugHeaders();
			Response.OutputStream.Write(bsJson, 0, bsJson.Length);
			Response.OutputStream.Flush();
			Response.Close();
		}

19 View Source File : GzipDataReader.cs
License : MIT License
Project Creator : aloneguid

private static void Decompress(Stream source, Stream destination)
      {
         if (source == null) throw new ArgumentNullException(nameof(source));
         if (destination == null) throw new ArgumentNullException(nameof(destination));

         using (var decompressor = new GZipStream(source, CompressionMode.Decompress, true))
         {
            decompressor.CopyTo(destination);
            destination.Flush();
         }
      }

See More Examples