1. Not finding help here? Sign up for a free 30min 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!

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?

    TIA!

    2. Relevant equations



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

    Mark44

    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

    Mark44

    Staff: Mentor

    Can you show me the section of your code where you try to open the file?
     
  6. Nov 26, 2013 #5
    void(main)
    {
    ifstream inFile;
    inFile.open("PORTLAND-ME.txt");
    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

    Student100

    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

    Mark44

    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:\..."
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Programming question
  1. Programming question (Replies: 5)

Loading...