CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2008
    Posts
    154

    Loading Content in same folder of exe

    been working on getting a nice release of my program, it needs to read files from this directory

    Code:
                string homePath = (Environment.OSVersion.Platform == PlatformID.Unix ||
                    Environment.OSVersion.Platform == PlatformID.MacOSX)
                    ? Environment.GetEnvironmentVariable("HOME")
                    : Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%");
                itemsContentPath = homePath + @"\My Documents\RPGProject\Content\Items";
    really it only needs to read from files for THIS directory >> "RPGProject"

    I want other people to use it but not have to worry about placing it \My Documents or not, since the exe is also in "RPGProject" is there a way to localize them so that no matter where RPGProject is, if exe and \Content\Items are there it should run just fine.

    how do I make??

    itemsContentPath = where ever I placed this @"\RPGProject\Content\Items";

  2. #2
    Join Date
    Jan 2011
    Posts
    11

    Re: Loading Content in same folder of exe

    Code:
    using System.IO;
    
    string exePath = Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location));

  3. #3
    Join Date
    Jun 2008
    Posts
    154

    Re: Loading Content in same folder of exe

    Awesome! Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured