免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6040 | 回复: 9
打印 上一主题 下一主题

[函数] windows下用什么函数查看指定的文件是否存在? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-08-30 15:25 |只看该作者 |倒序浏览
windows下用什么函数查看指定的文件是否存在?

论坛徽章:
3
2015年迎新春徽章
日期:2015-03-04 09:56:11数据库技术版块每日发帖之星
日期:2016-08-03 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
2 [报告]
发表于 2007-08-30 15:27 |只看该作者
_access

论坛徽章:
0
3 [报告]
发表于 2007-08-30 15:27 |只看该作者
fopen一下,出错了就是不存在

论坛徽章:
0
4 [报告]
发表于 2007-08-30 15:29 |只看该作者

  1. HANDLE CreateFile(
  2.   LPCTSTR lpFileName,
  3.   DWORD dwDesiredAccess,
  4.   DWORD dwShareMode,
  5.   LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  6.   DWORD dwCreationDisposition,
  7.   DWORD dwFlagsAndAttributes,
  8.   HANDLE hTemplateFile
  9. );

  10. dwCreationDisposition:
  11.     OPEN_EXISTING Opens the file. The function fails if the file does not exist.
  12. For a discussion of why you should use OPEN_EXISTING for devices, see Remarks.

复制代码

论坛徽章:
0
5 [报告]
发表于 2007-08-30 15:34 |只看该作者
FileExists

论坛徽章:
0
6 [报告]
发表于 2007-08-30 15:47 |只看该作者
#include <sys/stat.h>

int stat(const char *path, struct stat *buf);

论坛徽章:
0
7 [报告]
发表于 2007-08-30 15:59 |只看该作者
access

论坛徽章:
0
8 [报告]
发表于 2007-08-30 19:30 |只看该作者
FindFirstFile

论坛徽章:
0
9 [报告]
发表于 2007-08-30 23:19 |只看该作者
MSDN

The following code example shows you a minimal use of FindFirstFile.


#include <windows.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
  WIN32_FIND_DATA FindFileData;
  HANDLE hFind;

  printf ("Target file is %s.\n", argv[1]);
  hFind = FindFirstFile(argv[1], &FindFileData);
  if (hFind == INVALID_HANDLE_VALUE)
  {
    printf ("Invalid File Handle. GetLastError reports %d\n",
            GetLastError ());
    return (0);
  }
  else
  {
    printf ("The first file found is %s\n",
            FindFileData.cFileName);
    FindClose(hFind);
    return (1);
  }
}

论坛徽章:
0
10 [报告]
发表于 2007-08-31 09:30 |只看该作者
PathFileExists
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP