111,120
社区成员
发帖
与我相关
我的任务
分享
string serverpath = Server.MapPath("Documents//");
string material_path = serverpath + nfilename;
FileUpload1.PostedFile.SaveAs(material_path);
private void SendFiles(string[] filePaths, string[] directPaths)
{
string strIP = txtIP.Text.Trim();
int port = 8888;
Socket socket = this.GetSocket(strIP, port);
for (int i = 0; i < filePaths.Length; i++)
{
FileInfo info = new FileInfo(filePaths[i]);
byte[] temp = new byte[32];
using (FileStream fs = File.Open(filePaths[i], FileMode.OpenOrCreate))
{
//发送文件长度
byte[] lenArr = BitConverter.GetBytes(fs.Length);
socket.Send(lenArr);
socket.Receive(temp);
//发送文件路径
byte[] path = Encoding.ASCII.GetBytes(directPaths[i]);
socket.Send(path);
socket.Receive(temp);
//发送文件
byte[] data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
socket.Send(data);
}
}
socket.Close();
}