在指定目錄下創(chuàng)建文件夾
在博客里,有人問我這個問題:如何在指定目錄下創(chuàng)建文件夾。這個我還真的沒有做過。用CreateFile,似乎里面也沒有跟文件夾相關的任何東西。于是就在SDK中搜了一下,CreateDirectory。不錯,這個就可以用來創(chuàng)建文件夾。
下面來仔細學習一下這個API。
CreateDirectory
功能:
This function creates a new directory. If the underlying file system supports security on files and directories, the function applies a specified security descriptor to the new directory.
(創(chuàng)建一個新的文件夾。如果基本的文件系統(tǒng)在文件或文件夾上支持安全描述,那么該函數(shù)將在新建的文件夾上應用指定的安全描述)
原型:
BOOL CreateDirectory(
LPCTSTR lpPathName,
LPSECURITY_ATTRIBUTES lpSecurityAttributes
);
參數(shù):
lpPathName:包含將被創(chuàng)建的文件夾路徑的字符串,字符串的長度不超過MAX_PATH。
lpSecurityAttributes:忽略,設為NULL
返回值:
成功則返回非零,失敗則返回零。
備注:
Some file systems, such as NTFS file system, support compression or encryption for individual files and directories. On volumes formatted for such a file system, a new directory inherits the compression and encryption attributes of its parent directory.
In Windows CE 5.0 and later, full path canonicalization is performed before CreateDirectory processes a path name. As a result, trailing backslashes that may appear in a user-provided path name are ignored.
一些文件系統(tǒng),像NTFS文件系統(tǒng),對于個別的文件或目錄支持壓縮或加密。以卷格式化的文件系統(tǒng),一個新的目錄將繼承它父目錄的壓縮和加密特性。
在Windows CE 5.0或以后的版本中,全路徑的規(guī)范化將在CreateDirectory處理路徑名字前執(zhí)行。結果是,出現(xiàn)在用戶指定的路徑名中的反斜線將被忽略。
posted on 2009-07-21 18:14
Sandy 閱讀(2777)
評論(0) 編輯 收藏 引用 所屬分類:
Windows Mobile