• A question concerning programming etiquette
    4 replies, posted
Say you're developing a program that uses directory structures like [B][PathOfExecutable]\data[/B] as a means of storing application data. What would be the "proper" way of referencing the directory structures from within the code? Would hard coding the strings be the best way? Or maybe storing the paths in some other configuration file? I've always been curious about how other programmers go about this.
Use relative paths and forward slashes: [cpp] string text = File.ReadAllText("data/foobar.txt"); [/cpp] Problem solved (for the vast majority of cases). edit: The same sort of question was asked a few days ago, [url=http://www.facepunch.com/showthread.php?910202-What-do-you-need-help-with-Version-1&p=25522604&viewfull=1#post25522604]here's the long answer[/url].
[QUOTE=jA_cOp;25632476]Use relative paths and forward slashes: [cpp] string text = File.ReadAllText("data/foobar.txt"); [/cpp] Problem solved (for the vast majority of cases).[/QUOTE] Yeah this is how I normally do it.
I don't know if this is what you meant but I usually use a ResourceManager class to load all of my content within my data folder, and then I access it through that class to make sure I only load it once.
Also, don't forget to use [url=http://msdn.microsoft.com/en-us/library/system.io.path.aspx]Path[/url] when necessary.
Sorry, you need to Log In to post a reply to this thread.