public static string WriteFile(string vpath, string content) { string name = ""; string path = ""; IOPath.GetNameAndPath(vpath, out name, out path); return(WriteFile(path, name, content)); }
/// <summary> /// 允许写入JS与html,config等文件 /// </summary> /// <param name="vpath"></param> /// <param name="content"></param> /// <returns></returns> public static string WriteUnSafeFile(string vpath, string content) { string name = ""; string path = ""; IOPath.GetNameAndPath(vpath, out name, out path); DirPathDel(ref vpath); string dirPath = IOPath.VToP(vpath); //if (SafeC.FileNameCheck(new string[1] { fileName }) || !SafeC.VPathCheck(vpath)) { throw new Exception(vpath + fileName + "保存失败,不符合命名规范!"); } CreateDir(dirPath, ""); string ppath = dirPath + name; byte[] bytes = Encoding.UTF8.GetBytes(content); File.WriteAllBytes(ppath, bytes); return(IOPath.PToV(ppath)); }