Questions tagged [file-not-found]

An error, exit status, or exception that indicates that the file denoted by a specified pathname could not be found.

An error, exit status, or exception that indicates that the file denoted by a specified pathname could not be found. In other words, you're trying to access a file that doesn't exist where the code is expecting it to be.

This could occur as a result of many different actions, such as...

  1. The file doesn't actually exist, or was deleted before you could access it
  2. There is a spelling mistake in your pathname, or the pathname contains characters that aren't permitted in the pathname.
  3. You're using a relative pathname (such as file.txt) and the file doesn't exist in the default working directory for your application
  4. The code is getting confused due to different directory path indicators on different operating systems (ie / vs \)
  5. The programming language interprets the \ character in a String to be a escape character for a special symbol (such as \n indicating new-line), and you're using single \ slashes as directory indicators instead of \\ for a single escaped slash.
  6. In some languages, it could also give this exception if you aren't able to access the file due to security permissions.

Your code should be able to prevent or handle this condition, such as by doing the following...

  1. Detect - Many programming languages allow you to create a File object as a virtual representation of a physical file. Further to this, you can usually call a method or function that asks whether the file exists, such as exists();. This would allow you to check the file exists before you attempt to access it
  2. Prevent - If the user is selecting a file, present them with a FileChooser dialog rather than a text entry field. FileChooser dialogs echo the files that exist in the system, so spelling mistakes are avoided. If you're using relative paths, convert them to absolute paths if practical, or ensure you set the relative path location to a known directory before trying to access files relatively.
  3. Handle - Wrap your file access methods in exception-handling code, such as a try-catch block. This will allow you to catch unexpected exceptions, and perform an alternate operation, such as alerting the user of the error.
601 questions
3
votes
1 answer

Python - yahoo finance download all s&p 500 stocks

I am trying to run the code from here to download all S&P 500 stocks: https://pythonprogramming.net/sp500-company-price-data-python-programming-for-finance/ import bs4 as bs import datetime as dt import os import pandas_datareader.data as web import…
adrCoder
  • 3,145
  • 4
  • 31
  • 56
3
votes
1 answer

Python subprocess FileNotFoundError

I am trying to follow this blog on how to execute an R script from Python. I have the R script working fine from the command line using Rscript. Here's my Python code: import subprocess import os command = "C:\Program…
Tom Wagstaff
  • 1,443
  • 2
  • 13
  • 15
3
votes
3 answers

Angular 6 assets folder is not getting rendered on browser

I'm learning angular, I'm trying to load the local images inside the assets folder into main.component.html and I have set the path correctly, while I do alt+click on the path it opens the image. But the image was not loaded on the browser. The…
Avinash Dv
  • 109
  • 1
  • 2
  • 10
3
votes
1 answer

Not Found Error in NodeJS

I am new in NodeJS and I am trying to build an ecommerce application. I have readymade design and all the front end things with angularjs code. If I'm clicking on any menu then the page content changes along with the URL and is working fine but the…
Yash Parekh
  • 1,513
  • 2
  • 20
  • 31
3
votes
1 answer

Java FileNotFoundException with Absolute path - Cant Read or Execute, but file exists

I'm sure this has been answered, but ten different strategies hasn't worked on this issue. If I use C:\Users\Anny\Dropbox\SocialMediaOcto\instructions\Trees\instructions.txt as my absolute path for the file, IDEA cannot read or execute from…
Jayizzle
  • 532
  • 1
  • 6
  • 24
3
votes
2 answers

Cordova - Android - File not found error

When I run the command - cordova emulate android, I get the following error: Application Error - net::ERR_FILE_NOT_FOUND (file:///android_asset/www/index.html) CordovaActivity: /* Licensed to the Apache Software Foundation (ASF) under…
Smitha
  • 6,110
  • 24
  • 90
  • 161
3
votes
1 answer

Ppening an HTML file on localhost in XAMMP/apache 2.2 using subdirectories under htdocs

I have a site directory for html (dreamweaver CSS3) with lots of subdirectories that contain HTML files for a number of drop down menus. They work fine where they are, but they all have menus that are JavaScript and could be kept in a separate file.…
James Musser
  • 735
  • 5
  • 13
  • 18
3
votes
1 answer

Javascript - File saved to disk is stuck in Chrome's memory

I have this code: function saveFile(str, part) { var textFileAsBlob = new Blob([str], {type:"text/plain"}); var fileNameToSaveAs = "Parsed audio - part "+part; var downloadLink = document.createElement("a"); downloadLink.download =…
Amareth
  • 33
  • 3
3
votes
1 answer

CodeLite static library does not find include file

I've created a simple project to learn how to create a static library. I've created a new workspace in CodeLite and a new project and a new static library. In the static library I've got, inside a "include" folder a .h file called helloworld.h and…
user2233540
  • 427
  • 2
  • 5
  • 10
3
votes
2 answers

not found css file in cakephp without rewrite module

I'm having a problem with CakePHP, the CSS is not found. When I view the source code in my browser I can see the cake generic CSS link in the head section. But when I click on it to see the actual source code, I get a 404 not found error. i follow…
aya
  • 1,597
  • 4
  • 29
  • 59
3
votes
1 answer

Delphi for .NET does not find shared files in the .NET library search directories ("[DCC Error] F1026 File not found)

I have been trying to track down a problem with an installation of RAD Studio 2007 for some time. When compiling an ASP.NET application build with the .NET personability, I get an "[DCC Error] F1026 File not found error, where it reports that it…
Cary Jensen
  • 3,751
  • 3
  • 32
  • 55
3
votes
4 answers

How to get bash to ignore file-not-founds

In a (ba)sh script, how do I ignore file-not-found errors? I am writing a script that reads a (partial) filename from stdin, using: read file; $FILEDIR/$file.sh I need to give the script functionality to reject filenames that don't…
Nathan Ringo
  • 973
  • 2
  • 10
  • 30
2
votes
5 answers

getting file not found error in ios

Hi I am new to iOS development. Here is my problem. I am given a mac machine with 10.6.X and Xcode for the same. I am given a pre-written project for iPhone. I wanted to run the project on my iPhone so I had to upgrade my mac and Xcode to 10.7.x and…
Nik
  • 2,913
  • 7
  • 40
  • 66
2
votes
2 answers

Why C# library cannot be found in system32 folder?

Project has a reference to lib. If this lib lays near the executable, all works fine. But I need to put this lib to System32 folder. But in this case project fails, raising filenotfoundexception. I thought that I can feel myself free to put my libs…
yurart
  • 593
  • 1
  • 6
  • 23
2
votes
2 answers

ASP.NET MVC properly handling invalid URLs

I'm trying to properly handle and return a 404 for this URL: http://localhost:2867/dd./xml (notice the dot before the slash) In my current implementation I get 4 exceptions/errors in Application_Error. The first exception returned by…
pbz
  • 8,865
  • 14
  • 56
  • 70