http/File.aspx.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
public partial class File_File : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string msg = "";
string flag = "";
int total = 0;
long size_total=0;
int file_index = 0;//已存在文件part //保存一个分片到磁盘上
string name = Request["name"];
total = Convert.ToInt32(Request["total"]);
int index = Convert.ToInt32(Request["index"]);
size_total = Convert.ToInt64(Request["size"]);
var data = Request.InputStream;
string part = ""; //文件部分
string file_slice_dir = Server.MapPath("~/Upload/slices");
string dir = Server.MapPath("~/Upload/test1");
try
{ //从Request中取参数,注意上传的文件在Requst.Files中
if (Directory.Exists(dir) == false)
{
Directory.CreateDirectory(dir);
} //判断文件是否存在?
if (Directory.Exists(file_slice_dir) == false)
{
Directory.CreateDirectory(file_slice_dir);
}
string file = Path.Combine(file_slice_dir, name + "_" + index);
string part_all = Path.Combine(dir, name); //文件绝对路径
if (index>total) //服务器已经存在大文件
{
file_index = total;
flag = "ok";
}
else {
if (System.IO.File.Exists(file) == false)
{
file_index = total; //文件上传完成后,赋值100%
byte[] bytes = new byte[data.Length];
data.Read(bytes, 0, bytes.Length);
// 设置当前流的位置为流的开始
data.Seek(0, SeekOrigin.Begin);
// 把 byte[] 写入文件
FileStream fs = new FileStream(file, FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(bytes);
bw.Close();
后面还有 68 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
