file-exists

In C, checking for existence of file with name matching a pattern

心已入冬 提交于 2019-12-19 11:26:29
问题 I've seen a few methods for checking the existence of a file in C. However, everything I've seen works for a specific file name. I would like to check for any file that matches a particular pattern. For instance, maybe the pattern is "lockfile*" and "lockfileA", "lockfile.txt", or "lockfile.abc" would register in the check. The way I am doing this currently is to open the directory with opendir() then cycle through readdir() and try to match the pattern with name of each file returned. It

How to check if a file exists from a url

末鹿安然 提交于 2019-12-17 04:54:14
问题 I need to check if a particular file exists on a remote server. Using is_file() and file_exists() doesn't work. Any ideas how to do this quickly and easily? 回答1: You have to use CURL function does_url_exists($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_NOBODY, true); curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($code == 200) { $status = true; } else { $status = false; } curl_close($ch); return $status; } 回答2: You don't need CURL for that... Too much overhead

Deleting a file in VBA

谁都会走 提交于 2019-12-17 03:01:06
问题 Using VBA, how can I: test whether a file exists, and if so, delete it? 回答1: 1.) Check here. Basically do this: Function FileExists(ByVal FileToTest As String) As Boolean FileExists = (Dir(FileToTest) <> "") End Function I'll leave it to you to figure out the various error handling needed but these are among the error handling things I'd be considering: Check for an empty string being passed. Check for a string containing characters illegal in a file name/path 2.) How To Delete a File. Look

Deleting a file in VBA

懵懂的女人 提交于 2019-12-17 03:00:45
问题 Using VBA, how can I: test whether a file exists, and if so, delete it? 回答1: 1.) Check here. Basically do this: Function FileExists(ByVal FileToTest As String) As Boolean FileExists = (Dir(FileToTest) <> "") End Function I'll leave it to you to figure out the various error handling needed but these are among the error handling things I'd be considering: Check for an empty string being passed. Check for a string containing characters illegal in a file name/path 2.) How To Delete a File. Look

How to detect if a file exist in a project folder?

别来无恙 提交于 2019-12-14 00:24:06
问题 I am having a collection of images in my project folder. how to detect if a image exist in my project folder? I am using c#. Thanks. 回答1: if (System.IO.File.Exists("pathtofile")) //it exist else //it does not exist EDITED MY ANSWER AFTER THE COMMENT OF THE QUESTION: I copied the code and changed the exits function, this should work string type = Path.GetExtension(filepath); string path = @"image/" + type + ".png"; //if(System.IO.File.Exists(path)) I forgot to use the full path if (System.IO

Explain me 2 lines of this shell script

梦想的初衷 提交于 2019-12-13 10:28:50
问题 What does this mean? if [ -f $2/$1 ] and this line: cp $1 $2/$1 Does $2/$1 represent a file, because it's associated with -f ? #!/bin/bash if test $# -ne 2 then echo "Numbers of argument invalid" else if [ -f $2/$1 ] then echo "file already exist , replace ?" read return if test $return = 'y' then cp $1 $2/$1 else exit fi else cp $1 $2/$1 fi fi 回答1: ./script.sh "tmp.txt" "/project" echo $1 = tmp.txt echo $2 = /project $1 - file name $2 - directory if [ -f $2/$1 ] - checks if file exists, -f

How to check a file exist or not in unity android?

橙三吉。 提交于 2019-12-13 09:41:28
问题 I want to find the file in the path known and if it is pre-existing in android then trigger an event(enable/disable canvas) with it. Here is an example I used - public void FileChk(){ string filePath = "file://" + Application.temporaryCachePath + "/" + "folder23" + "/" + fileName; if (!fileName.Exists) { //event } else { //event } } what am I doing wrong here and how do I get this event to trigger when the file exists. 回答1: You can use the System.IO namespace. public void FileChk() { string

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

只谈情不闲聊 提交于 2019-12-12 08:21:53
问题 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 (no network). Why does exist takes forever? Is there a way to make it run FASTER? PS, This call to exist is part of Matlab's execution of loadlibrary . So, if you are calling loadlibrary and you don't know why it takes forever - this question is

Check file exists in a folder inside Directory in iPhone

余生颓废 提交于 2019-12-11 16:26:03
问题 I am new to iPhone, I want to check whether Myfile exists in folder inside DocumentDirectory ? For eg: Myfile.epub is one of my file and i want to check whether this file exists at my DestPath or not ? DestPath is my DocumentDirectory path. DestPath=/Users/krunal/Library/Application Support/iPhone Simulator/5.0/Applications/D414BC19-C005-4D93-896D-A6FB71DE4D21/Documents/Derivatives Any help will be appreciated. 回答1: This solution worked for me.. You don't want to give the entire part of your

actionscript 3: Check if an external file exists and if so unhide a movieClip

筅森魡賤 提交于 2019-12-11 08:24:57
问题 I'm trying to check if an external file exists and if so change the value of the visibility of a certain movie clip to true. I know how to do it in AS2, but I'm working in AS3. This is the AS2 code that I used to work with: onClipEvent (load) { fileExists = new LoadVars(); fileExists._parent = this; fileExists.onLoad = function(success) { //success is true if the file exists, false if it doesnt if (success) { _root.visiblity = 1; //the file exists } }; fileExists.load('visibility.exe');/