此文记录的是扩展名支持工具类。
/*** 扩展名工具类 Austin Liu 刘恒辉 Project Manager and Software Designer E-Mail: lzhdim@163.com Blog: http://lzhdim.cnblogs.com Date: 2024-01-15 15:18:00 使用说明: 1、在类里新建一个对象; ExtensionUtil _ExtensionUtil = new ExtensionUtil(new List<string> { ".exe", ".dll", ".ico" }); 2、判断是否在支持列表中; bool isSupport = _ExtensionUtil.IsSupport(".ico"); ***/ namespace Lzhdim.LPF.Utility { using System.Collections.Generic; /// <summary> /// 扩展名工具类 /// </summary> public class ExtensionUtil { private List<string> _ListSupportExt = null; /// <summary> /// 扩展名工具类 /// </summary> /// <param name="listSupportExt">是否支持的扩展列表</param> public ExtensionUtil(List<string> listSupportExt) { this._ListSupportExt = listSupportExt; } /// <summary> /// 是否扩展名支持的列表 /// </summary> public List<string> ListSupportExt { get => this._ListSupportExt; } /// <summary> /// 判断某扩展名是否在支持列表里 /// </summary> /// <param name="ext">扩展名,带.号</param> /// <param name="listExt">列表</param> /// <returns>true 支持;false 不支持</returns> public bool IsSupport(string ext) { if (_ListSupportExt.Contains(ext)) { return true; } else { return false; } } } }
Austin Liu 刘恒辉
Project Manager and Software Designer E-Mail:lzhdim@163.com Blog:https://lzhdim.cnblogs.com 欢迎收藏和转载此博客中的博文,但是请注明出处,给笔者一个与大家交流的空间。谢谢大家。 |