0

I've been building a game for the past couple of days. After i've reached certain milestones i'll C&P the project folder into my dropbox folder then create a new one in my visual studio folder.

I've run across a problem now however where when i'm trying to read from files the streamreader is trying to read from the previous folders directory.

SO for example in 'Project2' the reader is trying to read from a file in 'Project1'. How can I change this?

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
Lee Brindley
  • 6,242
  • 5
  • 41
  • 62
  • Please show code that have a problem - you are likely using relative path, but your current working folder does not match your expectations. – Alexei Levenkov Apr 15 '13 at 02:08

1 Answers1

2

First, you're most likely specifying an absolute directory ( "C:\Blah\BlahBlahblah..." ) or you've set the Working Directory to the wrong place.

Use relative paths or always store your data in a fixed place (the convention these days is to store your data is APPDATA. Storing it in a place like Program Files is a HORRIBLE CONVENTION. Don't do it when you release your program for realsies). Having tagged this with XNA, your root directory should also be specified to a relative place ("Content", "Data", etc.) so that when the executable boots up, it'll look in where the executable is, + inside the folder "Content" or "Data". That will make using the Content Loader easier.

Now, a general recommendation. You should never have to create a new project entirely to do version control. You're literally doing the work of any good free Version Control System (or like this one). Version control will make this much less painful for you.

Finally, a last tip for SO: describing your problem is cool, but what's even better than all of that is combined is posting the code that throws an error. Doing this allows us to figure out what exactly what wrong, because the skilled professionals of SO (of which I am trying to become one) have dealt with and know how to handle many kinds of exceptions and compilation errors (that, or our Google-Fu is stronk).

Community
  • 1
  • 1
  • Thanks for the answer and more importantly the advice! – Lee Brindley Apr 15 '13 at 04:20
  • @Fendorio No problem. :D Enjoy XNA and such. You might want to remember, though, that XNA is deprecated technology (it will still work on Windows 7 / 8, but it's not longer being supported by MS actively). If there's bugs left in the framework, they're there to stay. However, for the most part, it's a good framework and a great way to learn until you're ready for raw DirectX / SharpDX, or OpenGL. If you need to be more relevant, you can try using `MonoGame` too (google it, it's built to be 100% like XNA and uses SharpDX underneath to stay up to date). –  Apr 15 '13 at 04:22
  • Cool thanks :) Yeah i read that it's been discontinued, I'm an undergrad studying CS with games dev so next year i'll be working with Open GL etc, XNA seems good purely for busting out a quick prototype for a game idea though! – Lee Brindley Apr 15 '13 at 04:25
  • @Fendorio Yep, it definitely is. I worked with it extensively for a while myself before deciding it wasn't low-level enough to do all the fun stuff I'm doing with it now. :D I went to SharpDX, but after doing ti for a while decided "Hey, I'm already using what's basically DirectX. Why don't I just go back to C++ and use _real_ DirectX?" And that's how I ended up where I am today. I'm an undergrad too, btw, so I know how you feel. Good luck! :D –  Apr 15 '13 at 04:27