您的位置:首页 > 其它

23 windows_22_windows_Directory 文件系统 - 目录

2016-06-10 10:38 453 查看
windows_22_windows_Directory 文件系统 - 目录

// windows_22_windows_Directory.cpp : 定义控制台应用程序的入口点。

//


#include "stdafx.h"

#include <windows.h>


void UseDirectory( )

{

//创建目录

CreateDirectory( "D:\\Test", NULL );

//删除目录

RemoveDirectory( "D:\\Test2" );

//修改文件或者文件夹名称

MoveFile( "d:\\Test", "d:\\Test2" );

}

void ShowDirectory( )

{

//获取Windows目录

CHAR szWindows[MAX_PATH] = { 0 };

GetWindowsDirectory( szWindows, MAX_PATH );//当前系统安装目录

printf( "WindowsDirectory: %s\n", szWindows );

//获取System目录

CHAR szSystem[MAX_PATH] = { 0 };

GetSystemDirectory( szSystem, MAX_PATH );

printf( "SystemDirectory: %s\n", szSystem );

//获取临时文件的路径

CHAR szTemp[MAX_PATH] = { 0 };

GetTempPath( MAX_PATH, szTemp );

printf( "TempPath: %s\n", szTemp );

//获取应用程序当前目录

CHAR szCurrent[MAX_PATH] = {0};

GetCurrentDirectory( MAX_PATH, szCurrent );

printf( "CurrentDirectory: %s\n", szCurrent );

//设置当前目录

SetCurrentDirectory( "c:\\" );


GetCurrentDirectory( MAX_PATH, szCurrent );

printf( "CurrentDirectory: %s\n", szCurrent );


}

int _tmain(int argc, _TCHAR* argv[])

{

ShowDirectory( );

UseDirectory( );

return 0;

}

[/code]

来自为知笔记(Wiz)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: