コード例 #1
0
        /// <summary>
        /// 获取文件资源
        /// </summary>
        /// <param name="fileName">文件名称</param>
        /// <returns>文件路径</returns>
        public static string GetFileResource(this string fileName)
        {
            string fullPath = ToModelRoot(fileName);

            if (!File.Exists(fullPath))
            {
                FileOprateHelp.SaveFile(GetResourceStream(fileName), fullPath);
            }
            return(fullPath);
        }
コード例 #2
0
        /// <summary>
        /// 根据文件后缀获取资源文件
        /// </summary>
        /// <param name="directory">文件根目录</param>
        /// <param name="filter">文件后缀cs/dll等</param>
        /// <returns>所有文件路径集合</returns>
        public static List <string> GetFilesResourceByFilter(this string directory, string filter)
        {
            List <string> result   = new List <string>();
            Assembly      asm      = Assembly.GetExecutingAssembly();
            string        comparer = string.Empty;

            Array.ForEach(asm.GetManifestResourceNames(), (o) =>
            {
                if (o.EndsWith(filter))
                {
                    string fullPath = ToDllName(o);
                    FileOprateHelp.SaveFile(GetResourceStreamByFull(o), fullPath);
                    result.Add(fullPath);
                }
            });
            return(result);
        }