上传
This commit is contained in:
46
Tool/FileHelper.cs
Normal file
46
Tool/FileHelper.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tool
|
||||
{
|
||||
public class FileHelper
|
||||
{
|
||||
public void Transport(string file, string dst, string product)
|
||||
{
|
||||
string src;
|
||||
src = file;
|
||||
|
||||
FileStream inFileStream = new FileStream(src, FileMode.Open);
|
||||
if (!Directory.Exists(dst))
|
||||
{
|
||||
Directory.CreateDirectory(dst);
|
||||
}
|
||||
dst = dst + "\\" + product;
|
||||
FileStream outFileStream = new FileStream(dst, FileMode.OpenOrCreate);
|
||||
try
|
||||
{
|
||||
byte[] buf = new byte[inFileStream.Length];
|
||||
|
||||
int byteCount;
|
||||
|
||||
while ((byteCount = inFileStream.Read(buf, 0, buf.Length)) > 0)
|
||||
{
|
||||
outFileStream.Write(buf, 0, byteCount);
|
||||
}
|
||||
|
||||
inFileStream.Flush();
|
||||
outFileStream.Flush();
|
||||
}
|
||||
finally
|
||||
{
|
||||
inFileStream.Close();
|
||||
outFileStream.Close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user