/// <summary>
        /// 检查文件名是否有效。
        /// </summary>
        /// <param name="FileName"></param>
        public static Boolean CheckFileName(String fileName)
        {
            Boolean isValid = true;
            String[] strList = new String[] { " ", "/", "\"", @"\", @"\/", ":", "*", "?", "<", ">", "|", "\r\n" };

            if (String.IsNullOrEmpty(fileName))
            {
                isValid = false;
            }
            else
            {
                foreach (String errStr in strList)
                {
                    if (fileName.Contains(errStr))
                    {
                        isValid = false;
                        break;
                    }
                }
            }

            return isValid;
        }

  

posted on 2018-10-15 17:29  花生豆角  阅读(1973)  评论(0编辑  收藏  举报