返回信息流请问各位C++怎么实现获取当前路径以及该路径下的文件名?包括它所需要的头文件等?谢谢!!!
这是一条镜像帖。来源:北邮人论坛 / cpp / #8560同步于 2008/6/18
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
C++怎么实现获取当前路径以及该路径下的文件名?
heartcoolman
2008/6/18镜像同步9 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
GetProcessImageFileName
The GetProcessImageFileName function retrieves the name of the executable file for the specified process.
这个是获得当前进程执行文件镜像的
在unix下
1.char *getcwd(char *buf , size_t size)
把当前路径存在buf里
2.DIR *opendir(const char *pathname);
打开目录
{
3.struct dirent *readdir(DIR *dp)
4.readdir返回值的 ->d_name 就是文件名
5.int stat(const char *restrict pathname , struct stat *restrict buf)
得到文件信息
6.用buf.st_mode判断是文件还是目录
}循环执行readdir直到返回NULL
7.int closedir(DIR *dp)
关闭目录描述符