# Visual Basic > Visual Basic .NET > VS 2015 What am I doing wrong???

## groston

I wrote a simple VB.NET application. When the program, which writes a super-short text file to the desktop, is run from within Visual Studio, it runs just fine. However, when it is run by double-clicking the .exe file, this error appears: Unhanded exception has occurred... Access to the path "desktop" is denied. 

I checked explorer and the security in the desktop folder appears to be set correctly. What on earth is wrong?

----------


## OptionBase1

Does it work if you right-click the .exe file and choose "Run As Administrator"?

----------


## PlausiblyDamp

> I wrote a simple VB.NET application. When the program, which writes a super-short text file to the desktop, is run from within Visual Studio, it runs just fine. However, when it is run by double-clicking the .exe file, this error appears: Unhanded exception has occurred... Access to the path "desktop" is denied. 
> 
> I checked explorer and the security in the desktop folder appears to be set correctly. What on earth is wrong?


How are you getting the path to the desktop?

----------


## groston

Thanks for the replies.

OptionBase1: Same error

PausiblyDamp: Dim dirPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)

----------


## schoemr

Hi can you try:



```
.DesktopDirectory
```

Also, it is very hard to figure out your problem with only one line of code you provided. I would suggest you post the whole block...

----------

