Questions tagged [file-exists]

A "FileExists" method provides a mechanism to determine if a specified path/file exists.

Overview

FileExist methods, which are available in most languages, typically have a path/filename parameter and return a Boolean value, indicating whether the file exists.

Implementations

The following links provide reference to the method descriptions for various languages:

606 questions
16
votes
3 answers

Why does the python pathlib Path('').exists() return True?

I was expecting Path('') to be a path that does not exist because it does not correspond to a file or directory name. Why is this considered to exist? from pathlib import Path print(Path('').exists()) I assume there is an advantage gained by…
mattm
  • 5,851
  • 11
  • 47
  • 77
16
votes
2 answers

How can you check if a file exists before including/importing it in JSP?

Assuming that requestScope.importMe is expecting a path to a JSP file ... How…
qodeninja
  • 10,946
  • 30
  • 98
  • 152
13
votes
1 answer

Nodejs check if the given string is a valid file system path without actually checking the file system

How in nodejs can I check if the given string is a valid filesystem path without actually checking the filesystem. I am using telegram bot nodejs api and when sending files it checks if the file exist or not. But on the second time I am using the…
Exlord
  • 5,009
  • 4
  • 31
  • 51
13
votes
4 answers

In MATLAB exist( x, 'file' ) takes forever

I am using exist(x, 'file') to check for the existence of a file on my machine. The execution of this command takes FOREVER (over 10 seconds per call!). My matlabpath is not too long (about 200 entries) and all folders on path are on my local drive…
Shai
  • 111,146
  • 38
  • 238
  • 371
12
votes
1 answer

Can Jenkins pipeline function fileExist handle wildcards?

Can Jenkins pipeline function fileExist handle wildcards? I do have a zip file in the workspace folder. Following code gives hifalse: WORKSPACE = pwd() echo "hi"+fileExists("${WORKSPACE}/*.zip*") but then how can I do it?
Mike
  • 381
  • 1
  • 4
  • 12
12
votes
2 answers

Finding a file with a specific name with any extension

Please note that I want the compartment number to change.
Andy Cheeseman
  • 283
  • 1
  • 3
  • 13
11
votes
4 answers

SSIS Script task to check if file exists in folder or not

I want to check to see if a file exists in a particular folder from SSIS. How can I accomplish this?
user1429135
  • 145
  • 1
  • 2
  • 8
10
votes
1 answer

Checking a file existence on a remote SSH server using Python

I have two servers A and B. I'm suppose to send, let said an image file, from server A to another server B. But before server A could send the file over I would like to check if a similar file exist in server B. I try using os.path.exists() and it…
Teo Jie Wei
  • 109
  • 1
  • 1
  • 4
9
votes
4 answers

Java isFile(), isDirectory() without checking for existence

I want to check if a given String is a file or a directory, i've tried the methods isFile() and isDirectory() of the File class but the problem is that if the directory or file doesn't exist these methods returns false, because as stated in the…
aleroot
  • 71,077
  • 30
  • 176
  • 213
9
votes
6 answers

PHP Phar - file_exists() issue

My Phar script creates a new file with fwrite, which works fine, it creates the new file outside the phar, in the same directory as the phar file. But then when i use if(file_exists('file.php')) it doesn't pick it up. But then include and require do…
Lan
  • 1,874
  • 2
  • 20
  • 37
8
votes
3 answers

Checking if image exist in my local resources

net/C# application I have list of items. In the code behind: I want to assign a picture from my local resources for each item. the items name and the picture names are the same. The pictures are all in a "image" folder in my project. Example of how…
Y2theZ
  • 10,162
  • 38
  • 131
  • 200
8
votes
6 answers

php echo if two conditions are true

The actual code looks like this: if (file_exists($filename)) {echo $player; } else { echo 'something'; but it displays the player even if the id is not called from the url i need something like this: check if $filename exists and $id it is not…
m3tsys
  • 3,939
  • 6
  • 31
  • 45
8
votes
4 answers

PHP file_exists() returning false on some files

I'm having a strange problem with the file_exists() PHP function on a Linux server. When using file_exists to check the image is on the server before editing it, it will sometimes fail for no apparent reason. File paths are absolute and I've checked…
Ben
  • 1,435
  • 3
  • 10
  • 10
8
votes
2 answers

Tcl + Check file existence

I'm trying to check if a file exists or not in Tcl, but I can't seem to get a true result. Even though I know it is present. while {true} { if { [file exists $file_name] == 1} { exp_send "copy file.txt destination \r" …
c0d3rs
  • 107
  • 1
  • 2
  • 8
8
votes
3 answers

case sensitivity on Mac for file_exists()?

First off, Mac OS X is not my native operating system but since I'm comfortable in Ubuntu, it's been an easy transition for the most part. Being that it's Unix-based, I was under the impression this os was case-sensitive, but the file_exists()…
Mark1inLA
  • 196
  • 1
  • 7
1 2
3
40 41