同桌上课用手指进去了好爽_欧美丰满熟妇xxⅹⅹ性大i_成人av天天日天天拍拍_猛男gay帅男gay男男同志_欧美va天堂在线观看_人妻无码av中文系列三里桃花_亚欧免费无码在线观看_久久久精品国产亚洲av水_日韩在线免费看污污污_2021无码专区人妻系列日韩

首頁(yè) 優(yōu)化推廣 asp.net常用的文件與文件夾操作類(lèi)

asp.net常用的文件與文件夾操作類(lèi)

來(lái)源: | 時(shí)間:2013/10/30 16:24:44 |

.net常用的文件與文件夾操作類(lèi)

#region 引用命名空間
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
#endregion
namespace CommonUtilities
{
    /// <summary>
    /// 文件操作類(lèi)
    /// </summary>
    public class FileHelper
    {
        #region 檢測(cè)指定目錄是否存在
        /// <summary>
        /// 檢測(cè)指定目錄是否存在
        /// </summary>
        /// <param name="directoryPath">目錄的絕對(duì)路徑</param>        
        public static bool IsExistDirectory( string directoryPath )
        {
            return Directory.Exists( directoryPath );
        }
        #endregion
        #region 檢測(cè)指定文件是否存在
        /// <summary>
        /// 檢測(cè)指定文件是否存在,如果存在則返回true。
        /// </summary>
        /// <param name="filePath">文件的絕對(duì)路徑</param>        
        public static bool IsExistFile( string filePath )
        {
            return File.Exists( filePath );            
        }
        #endregion
        #region 檢測(cè)指定目錄是否為空
        /// <summary>
        /// 檢測(cè)指定目錄是否為空
        /// </summary>
        /// <param name="directoryPath">指定目錄的絕對(duì)路徑</param>        
        public static bool IsEmptyDirectory( string directoryPath )
        {
            try
            {
                //判斷是否存在文件
                string[] fileNames = GetFileNames( directoryPath );
                if ( fileNames.Length > 0 )
                {
                    return false;
                }
                //判斷是否存在文件夾
                string[] directoryNames = GetDirectories( directoryPath );
                if ( directoryNames.Length > 0 )
                {
                    return false;
                }
                return true;
            }
            catch ( Exception ex )
            {
                LogHelper.WriteTraceLog( TraceLogLevel.Error, ex.Message );
                return true;
            }
        }
        #endregion
        #region 檢測(cè)指定目錄中是否存在指定的文件
        /// <summary>
        /// 檢測(cè)指定目錄中是否存在指定的文件,若要搜索子目錄請(qǐng)使用重載方法.
        /// </summary>
        /// <param name="directoryPath">指定目錄的絕對(duì)路徑</param>
        /// <param name="searchPattern">模式字符串,"×"代表0或N個(gè)字符,"?"代表1個(gè)字符。
        /// 范例:"Log×.xml"表示搜索所有以Log開(kāi)頭的Xml文件。</param>        
        public static bool Contains( string directoryPath, string searchPattern )
        {
            try
            {
                //獲取指定的文件列表
                string[] fileNames = GetFileNames( directoryPath, searchPattern, false );
                //判斷指定文件是否存在
                if ( fileNames.Length == 0 )
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
      &n

服務(wù)熱線(xiàn)

153 8323 9821

功能和特性

價(jià)格和優(yōu)惠

網(wǎng)站和維護(hù)

推廣和優(yōu)化

微信服務(wù)號(hào)