| 
 
 工具方法,存文件比较方便。  
        //根路径
        string path = "";
        //判断是否存在这个文件夹
        public string ExitsPath(string dicName = "")
        {
            if (string.IsNullOrEmpty(this.path))
            {
                return this.path;
            }
            else
            {
                string path = this.path + "/" + dicName;
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                return path;
            }
        }
        //保存文件 参数1:文件字符串内容  参数2:文件名字 参数3:文件夹名字
        public void SaveFile( string content = "", string fileName = "",string dicName = "")
        {
           string pic_path = ExitsPath(dicName);
            File.WriteAllText(pic_path + "/" + fileName, content);
        }
        //保存文件 参数1:文件字节流内容  参数2:文件名字 参数3:文件夹名字
        public string SaveAllByte(byte[] allbyte, string fileName = "", string dicName = "")
        {
           string pic_path = ExitsPath(dicName);
            File.WriteAllBytes(pic_path + "/" + fileName, allbyte);
            return pic_path + "/" + fileName;
        }
        
        //读取文件     
        public string ReadText(string fileName = "", string dicName = "")
        {
           string pic_path = ExitsPath(dicName);
            return File.ReadAllText(pic_path + "/" + fileName);
        }  
                
        
    
 
 |