最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

VC判斷一個文件為目錄的方法

 更新時間:2014年10月28日 15:55:23   投稿:shichen2014  
這篇文章主要介紹了VC判斷一個文件為目錄的方法,在Windows應(yīng)用程序設(shè)計中非常具有實用價值,需要的朋友可以參考下

本文實例講述了VC判斷一個文件為目錄的方法,分享給大家供大家參考。具體實現(xiàn)方法如下:

這是一個自定義函數(shù),用于判斷一個文件是否為目錄:

復(fù)制代碼 代碼如下:
/**
 * check whether a file is a directory
 @return true if is a directory, else false(if file not exists, false)
 */
__declspec(dllexport) bool IsDirectory(const char* filename)
{
 
  DWORD dwAttr = ::GetFileAttributes(filename);  //得到文件屬性
 
  if (dwAttr == 0xFFFFFFFF)    // 文件或目錄不存在
    return false;
  else if (dwAttr&FILE_ATTRIBUTE_DIRECTORY)  // 如果是目錄
    return true;
  else
    return false;
}

以下是GetFileAttribute定義,摘自msdn:

Retrieves a set of FAT file system attributes for a specified file or directory.得到FAT文件系統(tǒng)的文件屬性

Parameters

lpFileName

The name of the file or directory.In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "http://?/" to the path. For more information, see Naming a File.文件名或目錄名。最大長度為系統(tǒng)的文件名最大長度。如果是unicode環(huán)境,需要調(diào)用這個函數(shù)的unicode版本。

Return Value

If the function succeeds, the return value contains the attributes of the specified file or directory.
如果函數(shù)成功了,返回值會包含以下文件屬性:
If the function fails, the return value is INVALID_FILE_ATTRIBUTES. To get extended error information, call GetLastError.
如果函數(shù)失敗,返回值是INVALID_FILE_ATTRIBUTES. 可以通過GetLastError獲取更詳細的出錯信息
The attributes can be one or more of the following values.
文件屬性可以是下列值的一個或多個的組合。

Return code/value Description

FILE_ATTRIBUTE_ARCHIVE
32
0x20

A file or directory that is an archive file or directory.

Applications use this attribute to mark files for backup or removal.

存檔文件

FILE_ATTRIBUTE_COMPRESSED
2048
0x800

A file or directory that is compressed.

For a file, all of the data in the file is compressed.

For a directory, compression is the default for newly created files and subdirectories.

壓縮文件

FILE_ATTRIBUTE_DEVICE
64
0x40

Reserved; do not use.

FILE_ATTRIBUTE_DIRECTORY
16
0x10

The handle that identifies a directory.

目錄文件

FILE_ATTRIBUTE_ENCRYPTED
16384
0x4000

A file or directory that is encrypted.

For a file, all data streams in the file are encrypted.

For a directory, encryption is the default for newly created files and subdirectories.

加密文件

FILE_ATTRIBUTE_HIDDEN
2
0x2

The file or directory is hidden. It is not included in an ordinary directory listing.

隱藏文件

FILE_ATTRIBUTE_NORMAL
128
0x80

A file or directory that does not have other attributes set.

This attribute is valid only when used alone.

 

FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
8192
0x2000

The file is not to be indexed by the content indexing service.

FILE_ATTRIBUTE_OFFLINE
4096
0x1000

The data of a file is not available immediately.

This attribute indicates that the file data is physically moved to offline storage. This attribute is used by Remote Storage, which is the hierarchical storage management software. Applications should not arbitrarily change this attribute.

FILE_ATTRIBUTE_READONLY
1
0x1

A file or directory that is read-only.

For a file, applications can read the file, but cannot write to it or delete it.

For a directory, applications cannot delete it.

FILE_ATTRIBUTE_REPARSE_POINT
1024
0x400

A file or directory that has an associated reparse point, or a file that is a symbolic link.

FILE_ATTRIBUTE_SPARSE_FILE
512
0x200

A file that is a sparse file.

FILE_ATTRIBUTE_SYSTEM
4
0x4

A file or directory that the operating system uses a part of, or uses exclusively.

FILE_ATTRIBUTE_TEMPORARY
256
0x100

A file that is being used for temporary storage.

File systems avoid writing data back to mass storage if sufficient cache memory is available, because typically, an application deletes a temporary file after the handle is closed. In that scenario, the system can entirely avoid writing the data. Otherwise, the data is written after the handle is closed.

FILE_ATTRIBUTE_VIRTUAL
65536
0x10000

A file is a virtual file.


希望本文所述對大家的VC程序設(shè)計有所幫助。

相關(guān)文章

  • OpenCV相機標定的全過程記錄

    OpenCV相機標定的全過程記錄

    這篇文章主要給大家介紹了關(guān)于OpenCV相機標定的相關(guān)資料,文中通過實例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2022-03-03
  • C語言中字符串與各數(shù)值類型之間的轉(zhuǎn)換方法

    C語言中字符串與各數(shù)值類型之間的轉(zhuǎn)換方法

    這篇文章主要介紹了C語言中字符串與各數(shù)值類型之間的轉(zhuǎn)換方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-03-03
  • C語言單鏈表的實現(xiàn)

    C語言單鏈表的實現(xiàn)

    單鏈表是一種鏈式存取的數(shù)據(jù)結(jié)構(gòu),用一組地址任意的存儲單元存放線性表中的數(shù)據(jù)元素。這篇文章主要介紹了C語言單鏈表的實現(xiàn) 的相關(guān)資料,需要的朋友可以參考下
    2016-04-04
  • c語言實現(xiàn)可自定義的游戲地圖

    c語言實現(xiàn)可自定義的游戲地圖

    這篇文章主要為大家詳細介紹了c語言實現(xiàn)可自定義的游戲地圖,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-01-01
  • 匯編語言常見錯誤信息中文注解

    匯編語言常見錯誤信息中文注解

    這篇文章主要介紹了匯編語言常見錯誤信息中文注解,本文收集大部分匯編中常見錯誤信息及對應(yīng)的中文注解,需要的朋友可以參考下
    2014-09-09
  • Qt qml實現(xiàn)動態(tài)輪播圖效果

    Qt qml實現(xiàn)動態(tài)輪播圖效果

    這篇文章主要為大家詳細介紹了Qt和qml實現(xiàn)動態(tài)輪播圖效果的相關(guān)知識,文中的示例代碼講解詳細,具有一定的借鑒價值,有需要的小伙伴可以參考一下
    2024-12-12
  • C++版本簡易Flappy bird

    C++版本簡易Flappy bird

    這篇文章主要介紹了C++版本簡易Flappy bird的相關(guān)資料,需要的朋友可以參考下
    2015-03-03
  • c++如何使用openssl接口來生成隨機數(shù)

    c++如何使用openssl接口來生成隨機數(shù)

    OpenSSL是一個強大的加密庫,不僅支持加密解密,還能生成隨機數(shù),設(shè)置過程包括下載資源文件、配置項目及修改屬性頁等步驟,確保庫文件正確包含,在Visual Studio中正確配置后,可使用RAND_bytes函數(shù)生成隨機數(shù),此過程需要注意文件路徑和附加目錄的設(shè)置
    2024-10-10
  • VC List Control控件如何刪除選中的記錄實例詳解

    VC List Control控件如何刪除選中的記錄實例詳解

    這篇文章主要介紹了VC List Control控件如何刪除選中的記錄實例詳解的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • 使用C語言中的time函數(shù)獲取系統(tǒng)時間

    使用C語言中的time函數(shù)獲取系統(tǒng)時間

    在C語言中可以使用time函數(shù)來獲取系統(tǒng)時間,以下對time函數(shù)進行了介紹,需要的朋友可以過來參考下
    2013-07-07

最新評論

万山特区| 泰和县| 沾益县| 德兴市| 南开区| 璧山县| 岳西县| 祁连县| 屯昌县| 安仁县| 卢氏县| 原平市| 余干县| 延安市| 从化市| 安陆市| 灌阳县| 石河子市| 泽库县| 通山县| 永丰县| 泸定县| 天门市| 广昌县| 保亭| 恩平市| 铜鼓县| 土默特左旗| 凤翔县| 洛南县| 香港 | 江都市| 德清县| 迭部县| 邻水| 彰武县| 木里| 高青县| 格尔木市| 岗巴县| 洪洞县|