ASP.NET单位绩效考核管理系统(11)

来源:xiaoniu168.com 作者:本站原创 添加时间:2012-03-03 点击数:28426

计算机毕业设计介绍:

5.2.1 文件传输及处理模块
该模块的详细功能为实时侦听29250端口,根据接收到客户端信息进行相关处理。客户端在请求文件传输或处理之前需要发送相关请求代号。如果发送ADD,那么代表客户端需要上传文件,即将上传文件及其存储路径;如果发送DEL,那么代表客户端请求删除文件,即将发送相关文件路径及文件名;如果发送LOOK,那么代表客户端需要下载查看相关文件,即将发送相关文件路径及文件名。
相关代码如下:

client = Listener.AcceptTcpClient();
                        netstream = client.GetStream();
                        StreamReader sr=new StreamReader(netstream);
                        string act=sr.ReadLine();
                        string path=sr.ReadLine();
                        string name=sr.ReadLine();
                        if (act == "ADD")
                        {
                            FileStream Fs = new FileStream(path+"\\"+name, FileMode.OpenOrCreate, FileAccess.Write);
                            while ((RecBytes = netstream.Read(RecData, 0, RecData.Length)) > 0)

                                Fs.Write(RecData, 0, RecBytes);
                              Fs.Close();

                            netstream.Close();
                            client.Close();
                            string sql = "insert into 附件表(部门名称月份类型文件名,文件名) values('" + path.Replace("C:\\附件目录\\", null).Replace("\\", null).ToString() +"','" + name + "')";
                            conn.Open();
                            SqlCommand cmd = new SqlCommand(sql,conn);
                            int a = cmd.ExecuteNonQuery();
                            conn.Close();
                        }
                        if (act =="DEL")
                        {
                            File.Delete(path + "\\" + name);
                            netstream.Close();
                            client.Close();
                        }

〖资料来源:计算机毕业论文 www.xiaoniu168.com

第12页为计算机毕业论文部分......

【联系方式】

【本站信誉】

用心做计算机毕业设计论文网