BOOL PathFileExists(LPCTSTR pszPath);
Determines if a file exists.
---经检测,该函数可以检测文件或目录是否存在!
Remarks
This function tests the validity of the file and path. It works only on the local file system or on a remote drive that has been mounted to a drive letter. It will return FALSE for remote file paths that begin with the UNC names //server or //server/share. It will also return FALSE if a mounted remote drive is out of service.
为了使用PathFileExists(),必须包含头文件"shlwapi.h",范例代码如下:
view sourceprint?
// Valid file path name (file is there).
|
char buffer_1[] = "C://TEST//file.txt" ;
|
// Invalid file path name (file is not there).
|
char buffer_2[] = "C://TEST//file.doc" ;
|
// Search for the presence of a file with a true result.
|
int retval = PathFileExists(lpStr1);
|
cout << "Search for the file path of : " << lpStr1 << endl;
|
cout << "The file requested /"" << lpStr1 << "/" is a valid file" << endl;
|
cout << "The return from function is: " << retval << endl;
|
cout << "The file requested " << lpStr1 << " is not a valid file" << endl;
|
cout << "The return from function is: " << retval << endl;
|
// Search for the presence of a file with a false result.
|
retval = PathFileExists(lpStr2);
|
cout << "/nThe file requested " << lpStr2 << " is a valid file" << endl;
|
cout << "Search for the file path of: " << lpStr2 << endl;
|
cout << "The return from function is: " << retval << endl;
|
cout << "/nThe file requested /"" << lpStr2 << "/" is not a valid file" << endl;
|
cout << "The return from function is: " << retval << endl;
|
编译后,却发现一个错误:error LNK2001: unresolved external symbol __imp__PathFileExistsA@4
网上搜索了下,发现是因为没有添加相应的lib。添加lib的方法网上有不少,这里使用下面的方法:
![](/assets/blank.gif)
这样,就可以通过编译了!
PathFileExists用法--使用#include相关推荐
- C语言中,#include的用法:#include 和 #include区别
C语言中,#include的用法:#include "" 和 #include<>区别 采用 " ":依次搜索当前目录.包括/I编译开关的路 ...
- PathFileExists用法--使用#include shlwapi.h
转载于:http://www.cnblogs.com/joeblackzqq/archive/2010/11/09/1872309.html BOOL PathFileExists(LPCTSTR p ...
- PathFileExists用法
BOOL PathFileExists(LPCTSTR pszPath); Determines if a file exists. ---经检测,该函数可以检测文件或目录是否存在! Remarks ...
- php 前台include用法,php include与require用法介绍
引用文件的方法有两种:require 及 include.两种方式提供不同的使用弹性. require 的使用方法如 require("MyRequireFile.php"); . ...
- android xml 中include的用法,Android include使用
安卓中,布局include主要是重用布局作用,当一个界面配置较多情况下,采用include可以大大增强 其可读性. eg:主布局include一个layout01布局,layout01布局中incl ...
- jsp中include 的两种用法
1.两种用法 静态include: <%@ inlcude file ="header.jsp" %> 此时引入的是静态的jsp文件,它将引入的jsp中的源代码原封不动 ...
- jsp中include的两个用法
我们都知道在jsp中include有两种情势,分别是 <%@ include file=" "%> <jsp:include page=" " ...
- 总结关于map的一些基本用法
map 的用法: #include map 是映射,一般用于字符串和整数之间的映射:实现哈希表:字符串之间的映射. map<映射之前的类型,映射之后的类型> 例如:map<char, ...
- sprintf-%s的用法
@2018-9-19 sprintf-%s的用法 1 #include <stdio.h> 2 #include <string.h> 3 4 5 char string[] ...
最新文章
- Android app开发捷径,让你少去踩坑
- C/C++-标准输入/输出重定向为文件输入/输出
- 设计一个百万级的消息推送系统
- 跟踪Makefile输出调试信息
- java改写weka中的算法_用Eclipse在Weka中嵌入新算法
- ios 开发框架原始雏形 01
- .NET Framework源码研究系列之---Delegate
- [蓝桥杯2018初赛]第几个幸运数-数论+枚举
- mysql count优化_MySQL count()函数及其优化
- python字符数组输出_python字符串格式化输出
- QT5+ROS程序开发
- OpenGL进阶演示样例1——动态画线(虚线、实线、颜色、速度等)
- Python异常:IndentationError: unexpected unindent
- PE学习.动手写PE.见缝插针
- Linux下高效实用的grep命令
- 怪物之心无法触发_《勇者斗恶龙 怪兽篇:旅团之心》怪物生方法及生规则研究 - 电玩巴士...
- 学士后java单元项目答案_北大青鸟学士后java工程师第二单元项目源代码
- uniapp uView 微信小程序弹框二维码canvas不显示,以及显示后跟随滑动的问题
- Android 入门教程:安装 Android Studio
- python基于pingouin包进行统计分析:使用tost函数执行独立双样本双单侧检验(TOST)、以dataframe的形式输出分析结果(包含p值、自由度、bound等)
热门文章
- 南艺附中 计算机音乐,南京艺术学院2018年音乐类本科招生考试科目及内容
- 源聚一堂 | 开源技术沙龙(深圳站)顺利举办
- 为什么超三成制造企业上市公司选择用友U9 cloud?
- div+css 上下左右移动
- 视觉震撼的数据可视化示例
- 独属程序员的表白方式?5分钟教会你用代码向女神画爱心,送玫瑰
- <数据库> datediff、timestampdiff函数的区别
- TypeScript基础之typeof 类型操作符
- springboot 配置 druid(德鲁伊)
- 用Python给头像或者照片加点水印!