1 Star 10 Fork 3

泽优软件/up6-asp-net

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
PathBuilder.cs 2.03 KB
一键复制 编辑 原始数据 按行查看 历史
using System.IO;
using System.Web;
using up6.db.model;
using up6.db.utils;
using up6.utils;
namespace up6.db.biz
{
/// <summary>
/// 路径生成器基类
/// 提供文件或文件夹的存储路径
/// </summary>
public class PathBuilder
{
/// <summary>
/// 根级存储路径,
/// </summary>
/// <returns></returns>
public string getRoot()
{
ConfigReader cr = new ConfigReader();
var uploadFolder = cr.m_files.SelectToken("$.IO.dir").ToString().Trim();
uploadFolder = uploadFolder.Replace("{root}", HttpContext.Current.Server.MapPath("/"));
return uploadFolder;
}
public virtual string genFolder(ref FileInf fd)
{
return string.Empty;
}
public virtual string genFile(string uid, ref FileInf f)
{
return string.Empty;
}
public virtual string genFile(string uid, string md5, string nameLoc)
{
return string.Empty;
}
/// <summary>
/// 相对路径转换成绝对路径
/// /2021/05/28/guid/nameLoc => d:/upload/2021/05/28/guid/nameLoc
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public string relToAbs(string path)
{
//统一路径格式
path = path.Replace("\\", "/");
string root = this.getRoot();
root = root.Replace("\\", "/");
//没有路径前缀->添加路径前缀
if (!path.StartsWith(root))
{
path = PathTool.combin(root, path);
}
return path;
}
/// <summary>
/// 将路径转换成相对路径
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public string absToRel(string path)
{
string root = this.getRoot();
path = path.Replace(root, string.Empty);
return path.Trim();
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/xproer/up6-asp-net.git
git@gitee.com:xproer/up6-asp-net.git
xproer
up6-asp-net
up6-asp-net
master

搜索帮助