コード例 #1
0
ファイル: FileResult.cs プロジェクト: martinrue/Tinyweb
        public void ProcessResult(IRequestContext request, IResponseContext response)
        {
            var fullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, FilePath);

            if (!File.Exists(fullPath))
            {
                throw new FileNotFoundException(String.Format("The file at {0} could not be found", fullPath));
            }

            response.AddHeader("Content-Disposition", String.Format("attachment; filename={0}", Path.GetFileName(fullPath)));
            response.ContentType = getContentType(fullPath);
            response.WriteFile(fullPath);
        }