code/Athena0.0.1/tool/File/FileDownHelper.cs
(开头部分) 6KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.IO;
using System.Threading;
using System.Web;
namespace Athena.tool.Code
{
public class FileDownHelper
{
public FileDownHelper()
{ }
public static string FileNameExtension(string FileName)
{
return Path.GetExtension(MapPathFile(FileName));
}
public static string MapPathFile(string FileName)
{
return HttpContext.Current.Server.MapPath(FileName);
}
public static bool FileExists(string FileName)
{
string destFileName = FileName;
if (File.Exists(destFileName))
{
return true;
}
else
{
return false;
}
}
public static void DownLoadold(string FileName, string name)
{
string destFileName = FileName;
if (File.Exists(destFileName))
{
FileInfo fi = new FileInfo(destFileName);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Buffer = false;
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(name, System.Text.Encoding.UTF8));
HttpContext.Current.Response.AppendHeader("Content-Length", fi.Length.ToString());
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.WriteFile(destFileName);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
}
}
public static void DownLoad(string FileName)
{
string filePath = MapPathFile(FileName);
long chunkSize = 204800; //指定块大小
byte[] buffer = new byte[chunkSize]; //建立一个200K的缓冲区
long dataToRead = 0; //已读的字节数
FileStream stream = null;
try
{
//打开文件
stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
dataToRead = stream.Length;
后面还有 98 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
