當前位置: 首頁>>代碼示例>>C#>>正文


C# HttpResponseBase.TransmitFile方法代碼示例

本文整理匯總了C#中System.Web.HttpResponseBase.TransmitFile方法的典型用法代碼示例。如果您正苦於以下問題:C# HttpResponseBase.TransmitFile方法的具體用法?C# HttpResponseBase.TransmitFile怎麽用?C# HttpResponseBase.TransmitFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Web.HttpResponseBase的用法示例。


在下文中一共展示了HttpResponseBase.TransmitFile方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: WriteEntireEntity

 protected override void WriteEntireEntity(HttpResponseBase response)
 {
     try
     {
         response.TransmitFile(FileName);
     }
     // ReSharper disable EmptyGeneralCatchClause
     catch
     // ReSharper restore EmptyGeneralCatchClause
     {
     }
 }
開發者ID:MulderFox,項目名稱:Main,代碼行數:12,代碼來源:RangeFilePathResult.cs

示例2: WriteEntityRange

        protected override void WriteEntityRange(HttpResponseBase response, long rangeStartIndex, long rangeEndIndex)
        {
            int length = Convert.ToInt32(rangeEndIndex - rangeStartIndex) + 1;

            try
            {
                response.TransmitFile(FileName, rangeStartIndex, length);
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch
            // ReSharper restore EmptyGeneralCatchClause
            {
            }
        }
開發者ID:MulderFox,項目名稱:Main,代碼行數:14,代碼來源:RangeFilePathResult.cs

示例3: SendContent

 public virtual bool SendContent(string url, HttpResponseBase response)
 {
     var file = GetFileNameFromConfig(url);
     try
     {
         response.TransmitFile(file);
         RRTracer.Trace("{0} transmitted from disk.", url);
         return true;
     }
     catch (FileNotFoundException)
     {
         try
         {
             response.TransmitFile(file.Insert(file.LastIndexOf('-'), "-Expired"));
             RRTracer.Trace("{0} was expired and transmitted from disk.", url);
             return true;
         }
         catch (FileNotFoundException)
         {
             return false;
         }
     }
 }
開發者ID:HKochniss,項目名稱:RequestReduce,代碼行數:23,代碼來源:LocalDiskStore.cs

示例4: Serve

 public void Serve(HttpResponseBase response, long offset, long length)
 {
     response.TransmitFile(FileName, offset, length);
 }
開發者ID:bmbsqd,項目名稱:dynamic-media,代碼行數:4,代碼來源:TransmitFileResult.cs

示例5: TryTransmitIfContains

 private bool TryTransmitIfContains(string id, HttpResponseBase response) {
     if (EnableAutoPurge) {
         QueueAutoPurge();
     }
     string path = BuildFilePath(id);
     lock (GetFileLockObject(id)) {
         if (File.Exists(path)) {
             response.TransmitFile(path);
             return true;
         }
         else {
             return false;
         }
     }
 }
開發者ID:sanyaade-mobiledev,項目名稱:ASP.NET-Mvc-2,代碼行數:15,代碼來源:DiskImageStore.cs

示例6: TransmitFile

        /// <summary>
        /// Writes file to response, adds correct headers based on Request headers and file attributes
        /// </summary>
        /// <param name="response"></param>
        protected virtual void TransmitFile(HttpResponseBase response)
        {
            var contentLength = ContentLength();
            response.StatusCode = SendRange() ? (int)HttpStatusCode.PartialContent : (int)HttpStatusCode.OK;

            response.AppendHeader(HttpHeaders.ContentLength, contentLength.ToString(CultureInfo.InvariantCulture));
            response.AppendHeader(HttpHeaders.AcceptRanges, "bytes");
            response.AppendHeader(HttpHeaders.ContentRange, string.Format("bytes {0}-{1}/{2}", _range.Start, _range.End, _file.Length));

            if(!string.IsNullOrWhiteSpace(_downloadFileName))
            {
                response.AddHeader("Content-Disposition", string.Format("attachment;filename=\"{0}\"", _downloadFileName));
            }

            try
            {
                response.TransmitFile(FileName, _range.Start, contentLength);
            }
            catch (Exception ex)
            {
                if(LogException != null)
                {
                    LogException(ex);
                }
            }
        }
開發者ID:eugene-kartsev,項目名稱:mvc.stream,代碼行數:30,代碼來源:ResumeFileResult.cs

示例7: WriteFile

 protected override void WriteFile(HttpResponseBase response) {
     response.TransmitFile(FileName);
 }
開發者ID:nhatquya,項目名稱:Samples,代碼行數:3,代碼來源:FilePathResult.cs

示例8: TryTransmitIfContains

        private bool TryTransmitIfContains (string id, HttpResponseBase response, string imgFile)
        {
            var tmpFiles = Directory.GetFiles (CachePath, id + "_*" + tmpFileExtension);

            // check if we have cache files
            if (tmpFiles.Length > 0)
            {
                // TODO: Log warning about duplicate cache entries

                // we expect to find just one file for each ID
                var tmpFile = tmpFiles [0];

                lock (GetFileLockObject(tmpFile))
                {
                    // get tmp short filename without extension
                    var tmpFileName = Path.GetFileNameWithoutExtension (Path.GetFileName (tmpFile));
                    // extract expire time

                    var expireTime = DateTime.MinValue;
                    var timeIndex = tmpFileName.LastIndexOf ("_") + 1;

                    if (timeIndex > 0)
                        expireTime = DateTime.FromFileTime (
                            Convert.ToInt64(tmpFileName.Substring (timeIndex)));

                    var hitCache = false;

                    if (imgFile == "")
                    {
                        // check if cache is expired
                        hitCache = expireTime >= DateTime.Now;
                    }
                    else if (timeIndex == 0)
                    {
                        // use original file last write time
                        var imgFileInfo = new FileInfo (imgFile);
                        var tmpFileInfo = new FileInfo (tmpFile);

                        hitCache = tmpFileInfo.LastWriteTime > imgFileInfo.LastWriteTime;
                    }

                    if (hitCache)
                    {
                        response.TransmitFile (tmpFile);
                        return true;
                    }
                    else
                    {
                        File.Delete (tmpFile);
                        return false;
                    }
                }
            }
            return false;
        }
開發者ID:roman-yagodin,項目名稱:R7.ImageHandler,代碼行數:55,代碼來源:DiskImageStore.cs


注:本文中的System.Web.HttpResponseBase.TransmitFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。