C++学习之:文件目录操作函数

1.创建目录(API)

  
  
  
  
  1. BOOL CreateDirectory(LPCTSTR pstrDirName);//pstrDirName是全路径 

2.删除目录(API)

  
  
  
  
  1. BOOL RemoveDirectory( LPCTSTR lpPathName ); 

3.判断目录是否存在(Shell Function)

  
  
  
  
  1. #include <shlwapi.h> 
  2. #pragma comment(lib, "shlwapi.lib")  
  3. if (PathIsDirectory(_T("d://temp")))  
  4.     AfxMessageBox(_T("存在")); 
  5. else  
  6.     AfxMessageBox(_T("不存在")); 

4.取得当前目录(API)

  
  
  
  
  1. DWORD GetCurrentDirectory( DWORD nBufferLength, LPTSTR lpBuffer ); 

5.取得执行文件所在目录(API)

  
  
  
  
  1. DWORD GetModuleFileName( HMODULE hModule, LPTSTR lpFilename, DWORD nSize ); 

6.取得功能目录(Shell Function)

  
  
  
  
  1. BOOL SHGetSpecialFolderPath( HWND hwndOwner,  LPTSTR lpszPath, int nFolder, BOOL fCreate); 

 

转载于:http://blog.csdn.net/chaoguodong/article/details/7349022

你可能感兴趣的:(文件目录,C++学习)