首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >是否将字符验证为文件路径?

是否将字符验证为文件路径?
EN

Stack Overflow用户
提问于 2011-10-16 00:18:52
回答 3查看 2.7K关注 0票数 3

确定字符是否为有效文件路径的最佳方法是什么?因此,CheckFilePath( "my*file.csv")将返回FALSE (在windows上*是无效字符),而CheckFilePath( "c:\\users\\blabla\\desktop\\myfile.csv" )将返回TRUE

请注意,文件路径可以是有效的,但不存在于磁盘上。

EN

Stack Overflow用户

发布于 2011-10-16 00:33:15

也许file.exists()就是你要找的?在帮助页面中:

代码语言:javascript
复制
file.exists returns a logical vector indicating whether the files named by its argument exist.
(Here ‘exists’ is in the sense of the system's stat call: a file will be reported as existing only
if you have the permissions needed by stat. Existence can also be checked by file.access, which
might use different permissions and so obtain a different result. 

还可以使用其他几个函数来访问计算机的文件系统,也可以在帮助页面中引用这些函数。

票数 1
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7779032

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档