1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Programming question

  1. Nov 26, 2013 #1
    1. The problem statement, all variables and given/known data

    I am trying to write a program in Visual Studio that opens a file downloaded to my computer. I have downloaded the file but Visual Studio can't seem to find it. Anyone know what I need to do?


    2. Relevant equations

    3. The attempt at a solution
  2. jcsd
  3. Nov 26, 2013 #2


    Staff: Mentor

    By defualt, Visual Studio looks in the directory where it puts the executable for your program. If the file you're looking for isn't there, VS won't find it. You'll probably need to include the full path to your file in your VS program.

    BTW what language is your program in? Visual Studio isn't a language.
  4. Nov 26, 2013 #3
    Hi Mark44,
    Thanks for your reply. I am aware that Visual Studio is not a language :) I am coding in C++. How does one include the full path to a file, anyway?
  5. Nov 26, 2013 #4


    Staff: Mentor

    Can you show me the section of your code where you try to open the file?
  6. Nov 26, 2013 #5
    ifstream inFile;
    inFile>>year>>month>>day>>etc, etc

    Nothing profound. This file exists in my computer as named. Not sure why VS can't find it.

  7. Nov 26, 2013 #6


    User Avatar
    Education Advisor
    Gold Member

    Open the folder containing your project. Drop the text file in there. You're done.
    Alternatively you can just use "something/somethingelse/somethingelseagain/file.txt"

    You'll have to figure out the something's, but I hope that won't be too hard.

    VS isn't going to do a search of the entire computer to find your file, you'll need to actually tell it where's it at.
    Last edited: Nov 26, 2013
  8. Nov 26, 2013 #7


    Staff: Mentor

    Like Student100 said, you'll have to either put the file in the default directory for the application, or include the full path, which will need to include the drive letter, like this: "c:\..."
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted

Similar Threads for Programming question Date
C: Question on file handling Nov 7, 2015
Programming assignment question (Java) Aug 15, 2014
MATLAB Programming Loops Question Oct 12, 2013
Linear Programming Exam Question Aug 8, 2013
Question about programming Jul 29, 2013