23 windows_22_windows_Directory 文件系统 - 目录

windows_22_windows_Directory 文件系统 - 目录

  1. // windows_22_windows_Directory.cpp : 定义控制台应用程序的入口点。
  2. //
  3. #include "stdafx.h"
  4. #include <windows.h>
  5. void UseDirectory( )
  6. {
  7. //创建目录
  8. CreateDirectory( "D:\\Test", NULL );
  9. //删除目录
  10. RemoveDirectory( "D:\\Test2" );
  11. //修改文件或者文件夹名称
  12. MoveFile( "d:\\Test", "d:\\Test2" );
  13. }
  14. void ShowDirectory( )
  15. {
  16. //获取Windows目录
  17. CHAR szWindows[MAX_PATH] = { 0 };
  18. GetWindowsDirectory( szWindows, MAX_PATH );//当前系统安装目录
  19. printf( "WindowsDirectory: %s\n", szWindows );
  20. //获取System目录
  21. CHAR szSystem[MAX_PATH] = { 0 };
  22. GetSystemDirectory( szSystem, MAX_PATH );
  23. printf( "SystemDirectory: %s\n", szSystem );
  24. //获取临时文件的路径
  25. CHAR szTemp[MAX_PATH] = { 0 };
  26. GetTempPath( MAX_PATH, szTemp );
  27. printf( "TempPath: %s\n", szTemp );
  28. //获取应用程序当前目录
  29. CHAR szCurrent[MAX_PATH] = {0};
  30. GetCurrentDirectory( MAX_PATH, szCurrent );
  31. printf( "CurrentDirectory: %s\n", szCurrent );
  32. //设置当前目录
  33. SetCurrentDirectory( "c:\\" );
  34. GetCurrentDirectory( MAX_PATH, szCurrent );
  35. printf( "CurrentDirectory: %s\n", szCurrent );
  36. }
  37. int _tmain(int argc, _TCHAR* argv[])
  38. {
  39. ShowDirectory( );
  40. UseDirectory( );
  41. return 0;
  42. }





posted @ 2016-06-10 10:38  -刀狂剑痴-  阅读(196)  评论(0编辑  收藏  举报