zoukankan      html  css  js  c++  java
  • c#文件路径

    c#判断文件路径是否正确

    if (!File.Exists(this.PathTBox.Text))//检测地图路径是否正确
    {
    MessageBox.Show(" 请修改为正确地图路径再保存");
    return;
    }
     #region 获取指定路径文件夹下子文件夹名称
            /// <summary>
            /// 获取指定路径文件夹下子文件夹名称
            /// </summary>
            /// <param name="sDirPath"></param>
            /// <returns></returns>
            public static List<string> GetChildDirectoryName(string sDirPath)
            {
                List<string> plstDirName = null;
                try
                {
                    string sDirName = string.Empty;
                    plstDirName = new List<string>();
                    DirectoryInfo _direcInfo = new DirectoryInfo(sDirPath);
                    DirectoryInfo[] _dirInfo = _direcInfo.GetDirectories();//返回当前目录的子目录
                    foreach (DirectoryInfo _directoryInfo in _dirInfo)
                    {
                        sDirName = _directoryInfo.Name;
                        if (!plstDirName.Contains(sDirName))
                        {
                            plstDirName.Add(sDirName);
                        }
                    }
                }
                catch (Exception )
                {
                }
                return plstDirName;
            }
            #endregion
     #region 获取指定文件夹下文件名称
            /// <summary>
            /// 获取指定文件夹下文件名称
            /// </summary>
            /// <param name="sDirPath"></param>
            /// <returns></returns>
            public static List<string> GetFiles(string sDirPath)
            {
                List<string> plstFileName = null;
                try
                {
                    FileInfo[] _fileInfo = null;
                    string sFileName = string.Empty;
                    plstFileName = new List<string>();
    
                    DirectoryInfo _direcInfo = new DirectoryInfo(sDirPath);
                    _fileInfo = _direcInfo.GetFiles();
                    foreach (FileInfo _fInfo in _fileInfo)
                    {
                        sFileName = _fInfo.Name;
                        if (!plstFileName.Contains(sFileName))
                        {
                            plstFileName.Add(sFileName);
                        }
                    }
                }
                catch (Exception )
                {
                }
                return plstFileName;
            }
            #endregion
     #region RGB颜色
            /// <summary>
            /// RGB颜色设置
            /// </summary>
            /// <param name="intR"></param>
            /// <param name="intG"></param>
            /// <param name="intB"></param>
            /// <returns></returns>
            public IRgbColor GetRgbColor(int intR, int intG, int intB)
            {
                IRgbColor pRgbColor = null;
                if (intR < 0 || intR > 255 || intG < 0 || intG > 255 || intB < 0 || intB > 255)
                {
                    return pRgbColor;
                }
                pRgbColor = new RgbColor();
                pRgbColor.Red = intR;
                pRgbColor.Green = intG;
                pRgbColor.Blue = intB;
                return pRgbColor;
            }
            #endregion
  • 相关阅读:
    时间好快,转眼又一周
    八月第二周
    八月第一周
    经济学人:埃航失事:波音信誉遭到危机(2)
    1109. 航班预订统计 --前缀和 和差分
    99. 激光炸弹 --前缀和+暴力 + 动态规划
    1108. Defanging an IP Address
    【mybatis】学习笔记 3动态语句 foreach generator使用【 小心生成系统中的数据库 如uesr表 country表】
    【mybatis】学习笔记 2 动态代理 输入输出参数 关联查询
    【JSP学习笔记】1jsp入门
  • 原文地址:https://www.cnblogs.com/janeaiai/p/4970782.html
Copyright © 2011-2022 走看看