Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get the current location of the Desktop so that I can automate a few things in my game. The current problem though is that following line doesn't work after I publish but it works in visual studios 2010.


I was wondering if there is a way around this.

share|improve this question
Hey and welcome to the community. I think your question requires a bit more detail. I. E. What kind of error are you getting? What does your code look like? When you walk through it with a debugger what doe the value of Environment.SpecialFolder.Desktop contain? Are you attempting to run as a user without admin rights? – Terrance Dec 10 '12 at 21:37
Are you publishing it for Windows? If so, I'm unable to reproduce - it works both in Visual Studio and when published for me (I'm creating a file on desktop). Attach the debugger and tell us what you see. – neeKo Dec 11 '12 at 2:27
Side note: I don't like games that mess with my desktop. – Archy Dec 11 '12 at 6:22
up vote 1 down vote accepted

It looks like Environment.SpecialFolder.Desktop is not supported by the XNA Framework.

The table here:

Shows the first column indicating if the XNA Framework supports it.


  • ApplicationData
  • Favorites
  • Programs
  • StartMenu
  • Startup
  • Personal
share|improve this answer
However, for Windows it does work in both cases (Visual Studio and Publish), and there's no reason it shouldn't seeing how it's all .NET anyway. – neeKo Dec 11 '12 at 2:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.