How do I structure my files so that I don't need to include the full file path?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alex Dransfield
    New Member
    • Jan 2011
    • 46

    How do I structure my files so that I don't need to include the full file path?

    I am running my project from a USB drive and when I mount the drive, it's not always mounted at the same location.

    I get the error message that my database cannot be found when I attempt to run the program.

    connection = new OleDbConnection (@"Provider=Mic rosoft.ACE.OLED B.12.0;Data Source=\ExamsHe lper\SysDB.accd b");

    This is the location, but I get the error message that it cannot be found at C:\ExamsHelper\ SysDB.accdb. This is not even where my project is located so I'm not sure why it is looking for it in C:\

    Which one of these is sufficient?
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    Where is the executable located? It's running off the USB drive too? That should actually work, I've used relative paths like that before.

    If you can't figure it out, see what is stored in Application.Sta rtupPath. You can always use that to build your folder paths.

    Comment

    • Alex Dransfield
      New Member
      • Jan 2011
      • 46

      #3
      All fixed, sorry! I forgot to change the question.

      Comment

      • GaryTexmo
        Recognized Expert Top Contributor
        • Jul 2009
        • 1501

        #4
        If by that you mean you solved it on your own, without my help, please post your solution and pick that as the best answer so people searching through the forums in the future get the correct information ;)

        Thanks!

        (And glad you got it figured out!)

        Comment

        Working...