47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
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();
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|