【实例简介】
可以实现文件上传到服务器的功能
【实例截图】
【核心代码】
public int UpSound_Request(string address, string fileNamePath, string saveName, ProgressBar progressBar)
{
int returnValue = 0;
//要上传的文件
FileStream fs = new FileStream(fileNamePath, FileMode.Open, FileAccess.Read);
//二进制对象
BinaryReader r = new BinaryReader(fs);
//时间戳
string strBoundary = "----------" DateTime.Now.Ticks.ToString("x");
byte[] boundaryBytes = Encoding.ASCII.GetBytes("\r\n--" strBoundary "\r\n");
//请求的头部信息
StringBuilder sb = new StringBuilder();
sb.Append("--");
sb.Append(strBoundary);
sb.Append("\r\n");