文件名称:工厂模式下文件流操作
文件大小:4.57MB
文件格式:ZIP
更新时间:2017-12-29 11:18:16
NET
工厂模式下文件流操作. public void InitBind() { var requestVal = Request.Params["FileName"]; if (requestVal.ToString().Trim() == "") { requestVal = "空数据"; } try { string fileTxtSrc = "/0107/File_upload/file/Read.txt"; // 文件路径 FileInfo fileInfo = new FileInfo(Server.MapPath(fileTxtSrc)); //if (fileInfo.Exists && fileInfo.Length >= 1024) //{ // fileInfo.Delete(); //} var count = fileInfo.Length; using (FileStream fs = fileInfo.OpenWrite()) { StreamWriter sw = new StreamWriter(fs); sw.BaseStream.Seek(0, SeekOrigin.End); sw.WriteLine("====================================="); sw.Write("添加日期为:" + DateTime.Now.ToString() + "\r\n"); sw.Write("日志内容为:" + requestVal + "\r\n"); sw.WriteLine("====================================="); sw.Flush(); sw.Close(); } } catch (Exception ex) { Response.Write("失败原因:" + ex.Message); } }