You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.0 KiB
C#
42 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace Web
|
|
{
|
|
public class PostFile
|
|
{
|
|
public string Name { get; private set; }
|
|
|
|
public string Type { get; private set; }
|
|
|
|
public byte[] Buffer { get; private set; }
|
|
|
|
public PostFile(HttpPostedFileBase file)
|
|
{
|
|
Name = file.FileName;
|
|
Type = file.ContentType;
|
|
byte[] temp = new byte[file.InputStream.Length];
|
|
file.InputStream.Read(temp, 0, (int)file.InputStream.Length);
|
|
Buffer = temp;
|
|
}
|
|
|
|
public PostFile(string name, string type, byte[] buffer)
|
|
{
|
|
Name = name;
|
|
Type = type;
|
|
Buffer = buffer;
|
|
}
|
|
|
|
public void SaveAs(string path)
|
|
{
|
|
using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
|
|
{
|
|
fs.Write(Buffer, 0, Buffer.Length);
|
|
}
|
|
}
|
|
}
|
|
|
|
} |