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
2
votes
1 answer

In Boost Property tree library, how I can handle file not found error in custom way (C++)

I want to read a json data from a file in C++ using boost libraries. Using property tree. I am new to programming, very new to c++ and its the first time i use boost library. I had some history in C many years ago. And i have a weeks experience in…
2
votes
1 answer

Can `No such file or directory` only mean that there is `No such file or directory`?

I am trying to train a network using caffe, but am getting a file-not-found exception: I0111 11:19:27.339706 5151 layer_factory.hpp:76] Creating layer data I0111 11:19:27.340117 5151 net.cpp:106] Creating Layer data I0111 11:19:27.340126 5151…
dimpol
  • 545
  • 9
  • 21
2
votes
2 answers

Xamarin Forms (running on iOS): Unable to file a storyboard file when building

I am having the following error, and even after I clean or rebuild, the error still appears. Isn't that file auto generated by Xamarin? /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets: Error:…
LittleFunny
  • 8,155
  • 15
  • 87
  • 198
2
votes
2 answers

VSCode "fileName" file not found

I finally set up the VSCode environment, just 1 remaining problem with #include as on the following image: I checked many google results with similar, but not the same problem. The thing is that it compiles and runs correctly, even the intellisense…
Lukas Salich
  • 959
  • 2
  • 12
  • 30
2
votes
4 answers

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\mswitajski\\Desktop\\alice.txt'

I'm trying to read in a text file to work with Word Clouds. Here is the syntax I'm trying: # Read the whole text. text = open(r'C:\Users\mswitajski\Desktop\alice.txt').read() But I keep getting the following error: FileNotFoundError: [Errno 2] No…
2
votes
1 answer

CoreAudio, AudioToolbox, AudioUnit etc. headers not found

I'm trying to build Ardour on OS X. I ran ./waf configure successfully, but trying to compile using ./waf results in numerous file-not-found when trying to #include…
Emil Laine
  • 41,598
  • 9
  • 101
  • 157
2
votes
2 answers

404 not found - but most certainly on server

Hello, I am getting this 404 not found error, while the file is most certainly on the server. All other files can be found, but I tried adding an icon folder and since then every file I upload to my server cannot be found by my browser. How is this…
Isaiah
  • 1,852
  • 4
  • 23
  • 48
2
votes
2 answers

cmath not found for Xcode

I am creating an iPhone app using OpenGL ES 2, and it uses both objective-c and c++. In it there is a header file for defining some vector properties, and this file includes cmath which then causes the error. Somebody suggested changing main.m to…
James
  • 173
  • 3
  • 12
2
votes
0 answers

How to use ViewerJS to display PDF (locally, without Webserver)

I am trying to view/open a PDF file with usage of a local HTML file and ViewerJS (without Webserver, i just open the HTML-File with a Browser). In short, it doesn't work. PDF is not displayed (Error: File not found) This is my directory…
Ben
  • 3,378
  • 30
  • 46
2
votes
2 answers

python subprocess module can't parse filename with special characters "("

I have a Python program that reads files and then tars them into tar balls of a certain size. One of my files not only has spaces in it but also contains parentheses. I have the following code: cmd = "/bin/tar -cvf " + tmpname + " '" + filename +…
2
votes
1 answer

Resources file is found by Gradle but not by Eclipse

In my gradle java project, if I run ./gradlew run -PappArgs="['file.dat']" it is compiled and my app succesfully uses the file located in /src/main/resources/. I have integrated Eclipse with gradle and imported my project into Eclipse. When I run…
Stephan Rozinsky
  • 553
  • 2
  • 6
  • 21
2
votes
0 answers

Xcode include header files from other sub project

I have a main xcode project (in C++) with many subprojects. In subproject A, I want to include some header files in subproject B, and B's product could be a dynamic library. How can I set up so that there will not be "file not found" error or…
2
votes
1 answer

Android - Audio recorder FileNotFound

I'm trying to record audio this.recorder = new android.media.MediaRecorder(); this.recorder.setAudioSource(android.media.MediaRecorder.AudioSource.MIC); …
david
  • 2,135
  • 4
  • 24
  • 34
2
votes
2 answers

Htaccess Rewrite Not Found

I'm using Mod Rewrite to remove index.php. I do not want to use queries. I want foo.com/bar to be interpreted as foo.com/index.php/bar. It does this fine, but gives me Not Found error. The requested URL /home/foo/www/index.php/bar was not found on…
Luke Burns
  • 1,911
  • 3
  • 24
  • 30
2
votes
2 answers

Where exactly should i add crossdomain.xml file?

i am trying to create a internet radio.... I use icecast2 for streaming..... edcast plugin with winamp to send the music to icecast... and the xspf web music player (http://musicplayer.sourceforge.net/) to connect the user to the icecast server and…
SpikETidE
  • 6,711
  • 15
  • 46
  • 62