locked
Using relative paths while developing RRS feed

  • Question

  • Hi All,

    I'd like to be able to use relative paths to images while developing as well as when I release my applicaton. I don't want to have to have to add the images to the resource dictionary as I need to all the user to simply drop images into the applications "Images" folder.

    The problem of course is that when I'm in Visual Studio and run the applicaton, the executable location becomes bin\Debug. So yes, I guess I could jsut make a copy of the folder and put that into bin\Debug, but there must be a better way?

    How does one do this in a clean way, so that I can jsut have a loose folder of images that get loaded at runtime, that works both when I'm in VS as well as when I release the application?

    Thanks

    Warrick

    Thursday, December 9, 2010 7:02 PM

Answers

  • Depending on your scenario, something like this might work:

          if (System.Diagnostics.Debugger.IsAttached)
          {
            Environment.CurrentDirectory = @"d:\testpath"; // or whatever path.
          }
    
    

    ... so when running under VS or any other debugger your application will think it's running under the path of Environment.CurrentDirectory.

    HTH,
    Matt


    SDET : Deployment/Hosting
    • Marked as answer by WarrickFitzs Saturday, December 11, 2010 4:00 PM
    Thursday, December 9, 2010 9:52 PM

All replies

  • Depending on your scenario, something like this might work:

          if (System.Diagnostics.Debugger.IsAttached)
          {
            Environment.CurrentDirectory = @"d:\testpath"; // or whatever path.
          }
    
    

    ... so when running under VS or any other debugger your application will think it's running under the path of Environment.CurrentDirectory.

    HTH,
    Matt


    SDET : Deployment/Hosting
    • Marked as answer by WarrickFitzs Saturday, December 11, 2010 4:00 PM
    Thursday, December 9, 2010 9:52 PM
  • Awesome. That's just what I needed - thanks!
    Saturday, December 11, 2010 4:00 PM