修改文件名别名

This commit is contained in:
2026-04-27 15:31:26 +08:00
parent 4d0cf75fa2
commit bee13e9027
2 changed files with 33 additions and 1 deletions
+25
View File
@@ -252,6 +252,8 @@ public partial class supplierBuildFile : System.Web.UI.Page
name = string.Join("-", list); name = string.Join("-", list);
return name; return name;
} }
private string formatMemo(object memo) private string formatMemo(object memo)
{ {
string m = memo.ToString(); string m = memo.ToString();
@@ -559,6 +561,23 @@ public partial class supplierBuildFile : System.Web.UI.Page
//CeErpTradeCell.ExecuteNonQuery(sql.ToString()); //CeErpTradeCell.ExecuteNonQuery(sql.ToString());
} }
static Dictionary<string, string> replaceRules = new Dictionary<string, string>
{
{ "皙贝", "白卡" },
{ "睿狐", "莱尼" },
{ "岚蝶", "安格" },
{ "琮纹", "刚古" },
{ "珠光", "珠光" },
{ "溪雪", "珠光" },
{ "雅柔", "雅柔" },
{ "萱姿", "雅柔" },
{ "草香", "草香" },
{ "芳怡", "草香" },
{ "金绒", "牛皮" },
{ "素芸", "棉卡" },
{ "玉蕊", "蛋壳" }
};
/// <summary> /// <summary>
/// 压缩大文件夹(分块处理) /// 压缩大文件夹(分块处理)
/// </summary> /// </summary>
@@ -590,6 +609,8 @@ public partial class supplierBuildFile : System.Web.UI.Page
// 使用 EnumerateFiles 减少内存使用 // 使用 EnumerateFiles 减少内存使用
var files = Directory.EnumerateFiles(sourceFolder, "*.*", SearchOption.AllDirectories); var files = Directory.EnumerateFiles(sourceFolder, "*.*", SearchOption.AllDirectories);
using (var fileStream = new FileStream(zipFilePath, FileMode.Create, FileAccess.Write, FileShare.None, 8192)) using (var fileStream = new FileStream(zipFilePath, FileMode.Create, FileAccess.Write, FileShare.None, 8192))
using (var zipArchive = new ZipArchive(fileStream, ZipArchiveMode.Create, true)) using (var zipArchive = new ZipArchive(fileStream, ZipArchiveMode.Create, true))
{ {
@@ -602,6 +623,10 @@ public partial class supplierBuildFile : System.Web.UI.Page
{ {
fileName = dealMemoName(fileName); fileName = dealMemoName(fileName);
} }
foreach (var rule in replaceRules)
{
fileName = fileName.Replace(rule.Key, rule.Value);
}
// 获取相对路径 // 获取相对路径
string relativePath = GetRelativePath(sourceFolder, file); string relativePath = GetRelativePath(sourceFolder, file);
+8 -1
View File
@@ -389,6 +389,10 @@ public partial class supplierDownload : System.Web.UI.Page
{ {
try try
{ {
foreach (var rule in replaceRules)
{
rnameList[i] = rnameList[i].Replace(rule.Key, rule.Value);
}
file.Add(files[i], rnameList[i]); file.Add(files[i], rnameList[i]);
addFiles.Add(files[i]); addFiles.Add(files[i]);
addCtid.Add(ctidLst[i]); addCtid.Add(ctidLst[i]);
@@ -432,7 +436,10 @@ public partial class supplierDownload : System.Web.UI.Page
{ {
string filePath = file; string filePath = file;
string dfile = Path.GetFileName(file); string dfile = Path.GetFileName(file);
foreach (var rule in replaceRules)
{
fname = fname.Replace(rule.Key, rule.Value);
}
FileStream fs = new FileStream(filePath, FileMode.Open); FileStream fs = new FileStream(filePath, FileMode.Open);
byte[] bytes = new byte[(int)fs.Length]; byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length); fs.Read(bytes, 0, bytes.Length);