FIle paths within the IDE (VS2008)

This is a discussion on FIle paths within the IDE (VS2008) within the C# Programming forums, part of the General Programming Boards category; i am currently referencing any files i use in my code from my Root Directory. Code: using (StreamReader stream = ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    85

    FIle paths within the IDE (VS2008)

    i am currently referencing any files i use in my code from my Root Directory.

    Code:
    using (StreamReader stream = new StreamReader(@"c:\map.txt"))
    i would now like to move all my files to a folder relative to the project.
    I have created a directory in the project folder and updated the code to the following.

    Code:
    using (StreamReader stream = new StreamReader(@"maps\map.txt"))
    but i keep gettings exceptions thrown when trying to debug due to not being able to see the file path.

    is there something i should be doing to tell the IDE that these are relative to my project ?

    i have looked at other code which appears to do this without any other steps that i can see.

    do i need to 'set' a path in the project options ?

    thanks

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I would guess that that's not the right relative directory. Does your debug directory contain a maps subdirectory (since that's where your program is)? If it's in your project directory, you need to go up a level first.

  3. #3
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    You need to make that new folder you speak of in the Debug or Release folder of bin depending on what mode you compile in. Also the exception should tell you the exact path where it is attempting to look so you can see where you need to move the files or adjust to.

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    85
    thanks tabstop

    my project directory has another folder with the same name inside it.
    inside that folder is :-

    folders :
    Bin
    Maps
    Obj
    Properties


    then various project and source files

    the bin folder does hold 2 more folders

    Debug
    Release

    i gather you are saying that the folder 'Maps' should be moved in the Debug folder ? to make it relevative to the program that is being debugged.

    if this is the case, does it also need to be moved in the release folder before i can 'Publish' or will the IDE take care of that ?

  5. #5
    Registered User
    Join Date
    Oct 2008
    Posts
    85
    Valaris - i fi look at the 'view detail' of the exception, all it says is 'parameter is not valid', i cannot see anything that shows paths in there - i have expanded all trees ( there is only one i can open up)

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    No the IDE won't take care of that. You can either add ..\.. to the front to get out of the Debug (or Release) and bin folders, or move Maps. (If you're planning to eventually publish the thing stand-alone, I would suggest the latter.)

  7. #7
    Registered User
    Join Date
    Oct 2008
    Posts
    85
    thanks both - have moved my folder into the dbug folder and it works now.

    do i need to move these into the release folder when i publish ?

    thanks in advance

    Edit* Thanks Tabstop crossed over on previouspost
    Last edited by deviousdexter; 11-07-2008 at 09:25 AM.

  8. #8
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Yes, because then the exe's releative root will be in the Release folder.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  3. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  4. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  5. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 09:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21