在做酷熊软件的时候需要做一个文件的传输功能,于是昨天就花了点时间写了个小的文件传输程序,C#写这些很容易,仅作交流之用
接收方:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
namespace ConsoleApplication1
{
class Class1
{
private Socket s;
int length = 1024;
public Class1()
{
TcpListener tc = new TcpListener(IPAddress.Parse("127.0.0.1"), 8888);
tc.Start();
s = tc.AcceptSocket();
byte[] bytesBuffer = new byte[length];
int count = s.Receive(bytesBuffer);
string fileName = Encoding.UTF8.GetString(bytesBuffer, 0, count);
int po