Hey, I'm very new when working with %userprofile% ect, The code I have now is.

When I press the button VB tell me It cannot find the directory. Please note I've tried %Userprofile%, %userprofile% Nothing will work :/ What's wrong? And How do I go about fixing this.

    Private Sub testbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testbutton.Click
        Dim s As String = Environment.GetEnvironmentVariable("UserProfile")
        Dim writeRes As New FileStream("C:\Users\UserProfile\AppData\Roaming\.ProjectName\Data\Test.exe", FileMode.Create)
        Dim binWrite As New BinaryWriter(writeRes)
        binWrite.Write(My.Resources.Test)
        binWrite.Close()

Edited 3 Years Ago by xXdragon15Xx

I think you can access the Application directory using:

My.Computer.FileSystem.SpecialDirectories

Then use the directory you wish.

If you are wanting to work with the current user just simply use:

My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData

To save alot of coding.

Edited 3 Years Ago by Begginnerdev

On Startup * Form load* I have

        My.Computer.FileSystem.CreateDirectory(Environment.ExpandEnvironmentVariables("%AppData% \.DragonLauncher"))
        My.Computer.FileSystem.CreateDirectory(Environment.ExpandEnvironmentVariables("%AppData% \.DragonLauncher\Launchers"))

how would I take a file from resources and move it to that folder ? * .DragonLauncher\launchers

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

Will go to my %appdata% Folder and roaming but It doesent have permission to place the exe in there how do I route it to my folders

Edited 3 Years Ago by xXdragon15Xx

Alright NVM all that, I'm tryin

 System.Diagnostics.Process.Start("C:\Users\%USERPROFILE%\AppData\Roaming\.DragonLauncher\DragonLauncherData.txt")

And Upon application startup I get "The system cannot find the file specified" But when I change the %userprofile% with my PC's name * profile* it will open the file no errors... What's a fix?

This article has been dead for over six months. Start a new discussion instead.