file-exists

Why does 'File.exists' return true, even though 'Files.exists' in the NIO 'Files' class returns false

时光总嘲笑我的痴心妄想 提交于 2019-11-29 03:33:35
I am trying to determine if a file exists in a network folder: // File name is "\\QWERTY\folder\dir\A123456.TXT" Path path = Paths.get("\\\\QWERTY\\folder\\dir\\A123456.TXT") Using NIO Files : Files.exists(path) == false Using File : path.toFile().exists() == true Using File seems to be the correct one according to our tests. Why does File work better than Files ? So, which is it? Can't be both! But wait, there is also Files.notExists(path) . When the network share file actually exists Files.exists(path): false Files.notExists(path): false path.toFile().exists(): true When the network share

Verify if file exists or not in C#

折月煮酒 提交于 2019-11-29 01:06:43
I am working on an application. That application should get the resume from the users, so that I need a code to verify whether a file exists or not. I'm using ASP.NET / C#. You can determine whether a specified file exists using the Exists method of the File class in the System.IO namespace: bool System.IO.File.Exists(string path) You can find the documentation here on MSDN . Example: using System; using System.IO; class Test { public static void Main() { string resumeFile = @"c:\ResumesArchive\923823.txt"; string newFile = @"c:\ResumesImport\newResume.txt"; if (File.Exists(resumeFile)) { File

Check if a file exists before calling openFileInput

爷,独闯天下 提交于 2019-11-28 18:18:22
To read a file in Android from your app's private storage area you use the function openFileInput() . My question is, is there a way to check if this file exists before calling this function? The function can throw a FileNotFoundException , but I feel like calling this and then doing something based on a try - catch is a bad practice. Using File.exist() seems like a strange thing to use also since it would require instantiating a class and I am not sure if just passing the name of the file to it would get it to find the file in the private area of my phone. coder_For_Life22 public boolean

PHP Rename File name if Exists Append Number to End

倖福魔咒の 提交于 2019-11-28 17:18:18
I'm trying to rename the file name of an image when it's uploaded if it exists, say if my file name is test.jpg and it already exists I want to rename it as test1.jpg and then test2.jpg and so on. With the code I've written its changing my file name like so test1.jpg and then test12.jpg any advice on fixing this would be great thank! PHP $name = $_FILES['picture']['name']; $actual_name = pathinfo($name,PATHINFO_FILENAME); $extension = pathinfo($name, PATHINFO_EXTENSION); $i = 1; while(file_exists('tmp/'.$actual_name.".".$extension)) { $actual_name = (string)$actual_name.$i; $name = $actual

Check if a file exists with Lua

丶灬走出姿态 提交于 2019-11-28 05:37:16
How can I check if a file exists using Lua? Try function file_exists(name) local f=io.open(name,"r") if f~=nil then io.close(f) return true else return false end end but note that this code only tests whether the file can be opened for reading. Using plain Lua, the best you can do is see if a file can be opened for read, as per LHF. This is almost always good enough. But if you want more, load the Lua POSIX library and check if posix.stat( path ) returns non- nil . tDwtp I will quote myself from here I use these (but I actually check for the error): require("lfs") -- no function checks for

Check if URL exists or not on Server

僤鯓⒐⒋嵵緔 提交于 2019-11-28 00:32:02
问题 This is my code which I am using to verify, URL exists or not on Server, but always getting not exist however link is alive Where I am doing mistake in my code, why I am always getting "doesnot exist !" public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String customURL = "http://www.desicomments.com/dc3/08/273858/273858.jpg"; boolean bResponse = exists

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

三世轮回 提交于 2019-11-27 23:19:42
问题 Assuming that requestScope.importMe is expecting a path to a JSP file <c:choose> <c:when test="${!empty requestScope.importMe && fileExists(requestScope.importMe) }"> <c:import url="${requestScope.importMe}" /> ... </c:choose> How can I check if the file exists before trying to include it so that an error is not thrown? I'd prefer a solution using JSTL tags. 回答1: Put it in a c:catch tag. It will catch any thrown Exception for you. <c:catch var="e"> <c:import url="${url}" /> </c:catch> <c:if

php check file name exist, rename the file

可紊 提交于 2019-11-27 22:39:57
问题 How do I check if file name exists, rename the file? for example, I upload a image 1086_002.jpg if the file exists, rename the file as 1086_0021.jpg and save, if 1086_0021.jpg is exist, rename 1086_00211.jpg and save , if 1086_00211.jpg is exist, rename 1086_002111.jpg and save... Here is my code, it only can do if 1086_002.jpg exist, rename the file as 1086_0021.jpg , maybe should do a foreach, but how? //$fullpath = 'images/1086_002.jpg'; if(file_exists($fullpath)) { $newpieces = explode(".

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

纵然是瞬间 提交于 2019-11-27 22:21:21
I want to check to see if a file exists in a particular folder from SSIS. How can I accomplish this? Variables: folder - string - C::\Temp\ file - string - 1.txt fileExists - boolean - False public void Main() { string folder = Dts.Variables["User::folder"].Value.ToString(); //@"C:\temp\"; string file = Dts.Variables["User::file"].Value.ToString(); //"a.txt"; string fullPath = string.Format(@"{0}\{1}", folder, file); Dts.Variables["User::fileExists"].Value = File.Exists(fullPath); Dts.TaskResult = (int)ScriptResults.Success; } You can use Foreach Loop Container and simply place all your items

Verify if file exists or not in C#

半世苍凉 提交于 2019-11-27 21:33:10
问题 I am working on an application. That application should get the resume from the users, so that I need a code to verify whether a file exists or not. I'm using ASP.NET / C#. 回答1: You can determine whether a specified file exists using the Exists method of the File class in the System.IO namespace: bool System.IO.File.Exists(string path) You can find the documentation here on MSDN. Example: using System; using System.IO; class Test { public static void Main() { string resumeFile = @"c: