Global.cs
上传用户:xtyqhl
上传日期:2022-06-07
资源大小:212k
文件大小:3k
源码类别:

Windows Mobile

开发平台:

Windows_Unix

  1. /****************************************************************
  2.  ** 文件名:Global.cs
  3.  ** 创建人:李万龙
  4.  ** 联  系:shenlongju@hotmail.com
  5.  ** 日  期:2008-05-05
  6.  ** 描  述:全局静态方法.
  7.  ** 修改人:
  8.  ** 日  期:
  9.  ** 描  述:
  10.  ** 版  本:1.0.0.0
  11.  ** Copyright (c) 2007-2008 3ESoft
  12. ******************************************************************/
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Text;
  16. using System.Windows.Forms;
  17. using System.IO;
  18. namespace _3ESoft.WindowsMobile.RSS
  19. {
  20.     public class Global
  21.     {
  22.         /// <summary>
  23.         /// 格式化新闻文件地址为:地址+文件名
  24.         /// </summary>
  25.         /// <param name="RSSUrl"></param>
  26.         /// <returns>本地路径</returns>
  27.         public static string FormatUrl(string RSSUrl)
  28.         {
  29.             string FilePath = AppRssDataPath();
  30.             RSSUrl = RSSUrl.Replace("%", "");
  31.             RSSUrl = RSSUrl.Replace("?", "");
  32.             RSSUrl = RSSUrl.Replace("/", "");
  33.             RSSUrl = RSSUrl.Replace(".", "");
  34.             RSSUrl = RSSUrl.Replace("http", "");
  35.             RSSUrl = RSSUrl.Replace(":", "");
  36.             FilePath += RSSUrl + ".img";
  37.             return FilePath;
  38.         }
  39.         /// <summary>
  40.         /// 本地RSS缓存目录
  41.         /// </summary>
  42.         /// <returns></returns>
  43.         public static string AppRssDataPath()
  44.         {
  45.             string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"3ESoftRSSData";
  46.             if (!Directory.Exists(path))
  47.                 Directory.CreateDirectory(path);
  48.             return path;
  49.         }
  50.         /// <summary>
  51.         /// 应用RSS显示格式目录
  52.         /// </summary>
  53.         /// <returns></returns>
  54.         public static string AppRssStylePath()
  55.         {
  56.             string path = ApplicationPath() + @"Style";
  57.             if (!Directory.Exists(path))
  58.                 Directory.CreateDirectory(path);
  59.             return path;
  60.         }
  61.         /// <summary>
  62.         /// 安装的配制文件目录
  63.         /// </summary>
  64.         /// <returns></returns>
  65.         public static string AppRssConfigFilePath()
  66.         {
  67.             string path = ApplicationPath()+ @"Config";
  68.             if (!Directory.Exists(path))
  69.                 Directory.CreateDirectory(path);
  70.             return path;
  71.         }
  72.         /// <summary>
  73.         /// 应用程序执行目录
  74.         ///     根据PPC还是SP应该不同
  75.         /// </summary>
  76.         /// <returns></returns>
  77.         static string ApplicationPath()
  78.         {
  79.              return Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
  80.         }
  81.     }
  82. }