byte[] bFileName = new byte[512];
r2Socket.Receive(bFileName);
String FileName = Encoding.UTF8.GetString(bFileName);
System.Windows.Forms.MessageBox.Show(FileName); // It's Ok. Show FileName = "text.jpg"
FileStream = new FileStream("D:\\" + FileName, FileMode.Create, FileAccess.Write);
文件流参数异常
path 是一个空字符串 (""),只包含空格,或者包含一个或多个无效字符。- 或 - path 指的是非文件设备,例如 NTFS 环境中的“con:”、“com1:”、“lpt1:”等。
为什么会发生?谢谢。
==
//CLIENT
byte[] bFileName = new byte[512];
Socket Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Socket.Connect(textBoxIP.Text, int.Parse(textBoxPORT.Text));
FileInfo sFileInfo = new FileInfo(textBoxFILE.Text);
string FileName = sFileInfo.Name;
bFileName = Encoding.UTF8.GetBytes(FileName);
Socket.Send(bFileName);
//SERVER
Socket rSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPAddress rIPAddress = Dns.GetHostEntry("localhost").AddressList[0];
IPEndPoint rIPEndPoint = new IPEndPoint(IPAddress.Any, int.Parse(textBoxPORT2.Text));
rSocket.Bind(rIPEndPoint);
rSocket.Listen(1);
byte[] bFileName = new byte[512];
r2Socket.Receive(bFileName);
String FileName = Encoding.UTF8.GetString(bFileName);