1.通过byte传输
把文件转换
public static byte[] ConvertToBinary(string Path)
{
FileStream
stream = new FileInfo(Path).OpenRead();
byte[] buffer
= new byte[stream.Length];
Console.WriteLine("The lenght of the file is "+buffer.Length);
stream.Read(buffer, 0, Convert.ToInt32(stream.Length));
return
buffer;
}
static byte[] buffer;
buffer = ConvertToBinary(path);
webService
FileStream fstream = new FileStream(filePath + fileName,
FileMode.Append);
try
{
//MemoryStream m = new MemoryStream(fileBt);
//m.WriteTo(fstream);
fstream.Write(fileBt, 0, fileBt.Length); //二进制转换成文件
fstream.Close();
//rst +=
"\r\n";
rst += "File Name is:" + fstream.Name + "\r\n";
rst += "File
Lenght is:" + fstream.Length + "\r\n";
rst += "File
Position is:" + fstream.Position + "\r\n";
}
catch (Exception ex)
{
//抛出异常信息
rst =
ex.ToString();
}
finally
{
fstream.Close();
}