服务端判断是否是文件
void RecMsg(object socket)
{
while (true)
{
Socket soket1 = socket as Socket;
byte[] bytes = new byte[1024 * 1024 * 2];
int length = soket1.Receive(bytes);
if (bytes[0] == 1)
{
SaveFileDialog sfd = new SaveFileDialog();
if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string filesavepath = sfd.FileName;
using (FileStream fs = new FileStream(filesavepath, FileMode.Create))
{
fs.Write(bytes, 1, length - 1);