# VB.NET My.Settings



## themusikid (Dec 12, 2008)

Hey forums, I have had this wracking my nerves for some time now and I just can't figure it out... I have been creating a launcher for programs on my USB flash drive (which means that the location of my VB.NET application will constantly be changing) and I would like to be able to do one of three things. I would like to either (1) force the app.config to be written/read to the same directory as the .exe for my program, (2) read/write to/from a .ini file in the same directory, or (3) (insert other method here).

Hopefully it is as easy as it should be, Microsoft is almost forcing people to write to the registry, and they aren't taking into account portable applications. Any help is, as always, greatly appreciated, even if it doesn't help at all =). Anyways thanks in advance.

P.S. If you need me to upload my program, say so.

TheMusiKid


----------



## Ent (Apr 11, 2009)

VB.net Settings aren't written to the registry, they're written to App Data in the user folder. I don't know of any way to change that location. What you could do is use the following code to extract the directory in which the App is stored, and then use normal File I/O to write your own configuration file and read it again on the Program's Load event.


```
My.Application.Info.DirectoryPath
```


----------



## pvc_ (Feb 18, 2008)

application.startuppath()


----------



## themusikid (Dec 12, 2008)

Ent said:


> VB.net Settings aren't written to the registry, they're written to App Data in the user folder. I don't know of any way to change that location. What you could do is use the following code to extract the directory in which the App is stored, and then use normal File I/O to write your own configuration file and read it again on the Program's Load event.
> 
> 
> ```
> ...


I know that the My.Settings are not written to the registry, I was just saying Microsoft only gives us two options: to write our setting to the host computer, or to write our settings to the host computer... I was just wondering if it was possible to save the user-defined application settings to the same directory as the .NET application.


----------

