确定字符是否为有效文件路径的最佳方法是什么?因此,CheckFilePath( "my*file.csv")将返回FALSE (在windows上*是无效字符),而CheckFilePath( "c:\\users\\blabla\\desktop\\myfile.csv" )将返回TRUE。
请注意,文件路径可以是有效的,但不存在于磁盘上。
发布于 2011-10-16 00:33:15
也许file.exists()就是你要找的?在帮助页面中:
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. 还可以使用其他几个函数来访问计算机的文件系统,也可以在帮助页面中引用这些函数。
https://stackoverflow.com/questions/7779032
复制相似问题