• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • C#使用WIN32API來遍歷文件和目錄[5]

    發表于:2007-05-14來源:作者:點擊數: 標簽:WIN32APIsummary文件遍歷目錄
    /// summary /// 搜索下一個 /// /summary /// returns操作是否成功/returns private bool SearchNext() { if (bolStartSearchFlag == false) return false; if (bolIsEmpty) return false; if (intSearchHandler == INVALID_HANDLE_VALUE) return false; int
        /// <summary>
       /// 搜索下一個
       /// </summary>
       /// <returns>操作是否成功</returns>
       private bool SearchNext()
       {
       if (bolStartSearchFlag == false)
       return false;
       if (bolIsEmpty)
       return false;
       if (intSearchHandler == INVALID_HANDLE_VALUE)
       return false;
       intLastErrorCode = 0 ;
       if (FindNextFile(intSearchHandler, ref myData) == false)
       {
       intLastErrorCode = System.Runtime.InteropServices.Marshal.GetLastWin32Error();
       this.CloseHandler();
       if (intLastErrorCode != 0 && intLastErrorCode != 0x12)
       {
       if (this.bolThrowIOException)
       WinIOError(intLastErrorCode , strSearchPath);
       else
       return false;
       }
       return false;
       }
       return true;
       }//private bool SearchNext()
      
       /// <summary>
       /// 更新當前對象
       /// </summary>
       /// <returns>操作是否成功</returns>
       private bool UpdateCurrentObject()
       {
       if (intSearchHandler == INVALID_HANDLE_VALUE)
       return false;
       bool Result = false;
       this.objCurrentObject = null;
       if ((myData.dwFileAttributes & 0x10) == 0)
       {
       // 當前對象為文件
       this.bolIsFile = true;
       if (this.bolSearchForFile)
       Result = true;
       }
       else
       {
       // 當前對象為目錄
       this.bolIsFile = false;
       if (this.bolSearchForDirectory)
       {
       if (myData.cFileName == "." || myData.cFileName == "..")
       Result = false;
       else
       Result = true;
       }
       }
       if (Result)
       {
       if (this.bolReturnStringType)
       this.objCurrentObject = myData.cFileName;
       else
       {
       string p = System.IO.Path.Combine(this.strSearchPath, myData.cFileName);
       if (this.bolIsFile)
       {
       this.objCurrentObject = new System.IO.FileInfo(p);
       }
       else
       {
       this.objCurrentObject = new System.IO.DirectoryInfo(p);
       }
       }
       this.intSearchedCount++;
       }
       return Result;
       }//private bool UpdateCurrentObject()
      
       #endregion
      
      }//public class FileDirectoryEnumerator : System.Collections.IEnumerator 
      

    原文轉自:http://www.kjueaiud.com

    評論列表(網友評論僅供網友表達個人看法,并不表明本站同意其觀點或證實其描述)
    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>