public void WriteTo(Stream stream)
 {
     using (var fs = new FileStream(this.FilePath, FileMode.Open, FileAccess.Read))
     {
         fs.WriteTo(stream);
         stream.Flush();
     }
 }
        public void WriteTo(Stream responseStream)
        {
            using (var fs = new FileStream(this.FilePath, FileMode.Open, FileAccess.Read))
            {
                fs.Position = Adler32ChecksumLength;

                fs.WriteTo(responseStream);
                responseStream.Flush();
            }
        }
		public static void WriteFile(this IHttpResponse httpRes, string filePath)
		{
			var aspNetRes = httpRes as HttpResponseWrapper;
			if (aspNetRes != null)
			{
				aspNetRes.Response.WriteFile(filePath);
				return;
			}

			using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
			{
				fs.WriteTo(httpRes.OutputStream);
			}

            httpRes.EndServiceStackRequest();
        }
        public static void TransmitFile(this IResponse httpRes, string filePath)
		{
			var aspNetRes = httpRes as AspNetResponse;
			if (aspNetRes != null)
			{
				aspNetRes.Response.TransmitFile(filePath);
				return;
			}

			using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
			{
				fs.WriteTo(httpRes.OutputStream);
			}

            httpRes.EndRequest();
        }
        public static void TransmitFile(this IHttpResponse httpRes, string filePath)
        {
            var aspNetRes = httpRes as HttpResponseWrapper;
            if (aspNetRes != null)
            {
                aspNetRes.Response.TransmitFile(filePath);
                return;
            }

            using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                fs.WriteTo(httpRes.OutputStream);
            }

            //httpRes.Close();
        }
        public static void WriteFile(this IResponse httpRes, string filePath)
        {
#if !NETSTANDARD1_6
            var aspNetRes = httpRes as ServiceStack.Host.AspNet.AspNetResponse;
            if (aspNetRes != null)
            {
                aspNetRes.Response.WriteFile(filePath);
                return;
            }
#endif

            using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                fs.WriteTo(httpRes.OutputStream);
            }

            httpRes.EndRequest();
        }
        public static void WriteFile(this IHttpResponse httpRes, string filePath)
        {
            var aspNetRes = httpRes as HttpResponseWrapper;
            if (aspNetRes != null)
            {
                aspNetRes.Response.WriteFile(filePath);
                return;
            }

            using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                fs.WriteTo(httpRes.OutputStream);
            }

            ServiceStack.WebHost.Endpoints.EndpointHost.AddGlobalResponseHeaders(httpRes);
            httpRes.Close();
        }