chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace 報到系統.Forms
|
||||
{
|
||||
public partial class Home : PageBase
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string LatestClientPackage()
|
||||
{
|
||||
var latestClientPackage = GetLatestClientPackageFileName();
|
||||
if (!string.IsNullOrEmpty(latestClientPackage))
|
||||
{
|
||||
return ResolveUrlWithSysVer(string.Format("~/Assets/Downloads/{0}", latestClientPackage));
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得最新的客戶端安裝包檔案名稱
|
||||
/// 從 Assets/Downloads 目錄下查找 "報到系統客戶端_*.zip" 檔案
|
||||
/// 按檔名排序取最大的那一個
|
||||
/// </summary>
|
||||
private string GetLatestClientPackageFileName()
|
||||
{
|
||||
try
|
||||
{
|
||||
string downloadDir = Server.MapPath("~/Assets/Downloads/");
|
||||
|
||||
if (!Directory.Exists(downloadDir))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
DirectoryInfo dirInfo = new DirectoryInfo(downloadDir);
|
||||
FileInfo[] files = dirInfo.GetFiles("報到系統客戶端_*.zip");
|
||||
|
||||
if (files.Length == 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
// 按檔名排序,取最後一個(最大的那個)
|
||||
string latestFileName = files.OrderBy(f => f.Name).LastOrDefault()?.Name;
|
||||
|
||||
return latestFileName ?? string.Empty;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user