Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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. –  Niko Drašković 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

1 Answer 1

up vote 1 down vote accepted

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

The table here: http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx

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. –  Niko Drašković 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.