标签: file-exists

如何检查文件是否存在而没有例外?

如何在不使用该try语句的情况下查看文件是否存在?

python file file-exists

5290
推荐指数
41
解决办法
372万
查看次数

在VBA中删除文件

使用VBA,我该怎么做:

  1. 测试文件是否存在,如果存在,
  2. 删除它?

file-io vba file-exists delete-file

114
推荐指数
6
解决办法
44万
查看次数

如何检测Vimscript中是否存在特定文件?

我正在Vimscript中寻找一种优雅的方法来检查函数中当前目录中是否存在文件.

我想出了这个,但不确定这是否是最优雅的解决方案(我将设置vim选项,如果它存在) - 是否有任何方法不必再进行文件名的比较 - 可能使用不同的__CODE__内置函数( ?):

:function! SomeCheck()
:   if findfile("SpecificFile", ".") == "SpecificFile"
:       echo "SpecificFile exists"
:   endif
:endfunction
Run Code Online (Sandbox Code Playgroud)

vim file-exists

94
推荐指数
4
解决办法
3万
查看次数

如何在c ++中检查Qt中是否存在文件

如何在Qt中检查给定路径中是​​否存在文件?

我目前的代码如下:

QFile Fout("/Users/Hans/Desktop/result.txt");

if(!Fout.exists()) 
{       
  eh.handleError(8);
}  
else
{
  // ......
}
Run Code Online (Sandbox Code Playgroud)

但是当我运行代码时,handleError即使我在路径中提到的文件不存在,它也没有给出指定的错误消息.

c++ qt file-exists

71
推荐指数
4
解决办法
8万
查看次数

63
推荐指数
6
解决办法
6万
查看次数

检查目录是否存在的便携方式[Windows/Linux,C]

我想检查一个给定的目录是否存在.我知道如何在Windows上执行此操作:

BOOL DirectoryExists(LPCTSTR szPath)
{
  DWORD dwAttrib = GetFileAttributes(szPath);

  return (dwAttrib != INVALID_FILE_ATTRIBUTES && 
         (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
}
Run Code Online (Sandbox Code Playgroud)

和Linux:

DIR* dir = opendir("mydir");
if (dir)
{
    /* Directory exists. */
    closedir(dir);
}
else if (ENOENT == errno)
{
    /* Directory does not exist. */
}
else
{
    /* opendir() failed for some other reason. */
}
Run Code Online (Sandbox Code Playgroud)

但我需要一种可移植的方式来做这个..有没有办法检查目录是否存在,无论我使用什么操作系统?也许是C标准库的方式?

我知道我可以使用预处理程序指令并在不同的操作系统上调用这些函数,但这不是我要求的解决方案.

我最终用这个,至少现在:

#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>

int dirExists(const char *path)
{
    struct stat info;

    if(stat( path, &info ) != …
Run Code Online (Sandbox Code Playgroud)

c directory file file-exists

59
推荐指数
4
解决办法
8万
查看次数

使用URL检查远程服务器上是否存在文件

如果远程服务器(由HTTP提供服务)上存在文件,并且有URL,我该如何检查Java?我不想下载文件,只检查它的存在.

java url networking http file-exists

58
推荐指数
3
解决办法
7万
查看次数

CMake检查是否存在本地文件

在我的CMake脚本中,我想看看我的系统上是否有文件,如果有文件,请使用默认文件.这是代码:

find_file(
          ${project_name}_${customer}_config 
          ${ROOT}/configuration/${customer}/configuration.${project_name}.xml
)

if(NOT ${${project_name}_${customer}_config} STREQUAL
   ${project_name}_${customer}_config-NOTFOUND )
        configure_file(${ROOT}/configuration/${customer}/configuration.${project_name}.xml
                       ${CMAKE_CURRENT_BINARY_DIR}/conf/configuration.xml)
else()
    configure_file(${FAPP_ROOT}/configuration/Default/configuration.${project_name}.xml
                   ${CMAKE_CURRENT_BINARY_DIR}/conf/configuration.xml)
endif()
Run Code Online (Sandbox Code Playgroud)

但似乎这不起作用.

检查CMake中是否存在文件的正确方法是什么?

file cmake file-exists

56
推荐指数
4
解决办法
5万
查看次数

如何从URL中检查文件是否存在

我需要检查远程服务器上是否存在特定文件.使用is_file()file_exists()不起作用.任何想法如何快速,轻松地做到这一点?

php curl file fsockopen file-exists

46
推荐指数
4
解决办法
10万
查看次数

检查php中是否存在文件

if (!(file_exists(http://mysite.com/images/thumbnail_1286954822.jpg))) {   
$filefound = '0';                         
}
Run Code Online (Sandbox Code Playgroud)

为什么这不起作用?

php file-exists

35
推荐指数
5
解决办法
11万
查看次数

标签 统计

file-exists ×10

file ×4

file-io ×2

php ×2

c ×1

c++ ×1

cmake ×1

curl ×1

delete-file ×1

directory ×1

fsockopen ×1

http ×1

java ×1

lua ×1

networking ×1

python ×1

qt ×1

url ×1

vba ×1

vim ×1