Home > Back-end >  VB.NET Cannot access user's temp folder
VB.NET Cannot access user's temp folder

Time:07-27

So, my problem is, i want my program to delete all files inside the user's temp folder. To go there and see if it works, i press WIN R and type "%temp%" and hit enter...

It shows C:\Users\EDUARD~1\AppData\Local\Temp

But if i go into the users folder, my friend's user folder is named "EduardoPC".

If i press WIN R and type "%userprofile%", it shows this path: C:\Users\EduardoPC

Im using:

Dim User As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
Dim PersonalTemp As String = User & "\AppData\Local\Temp\"

And also tried to use:

Dim User As String = SystemInformation.UserName
Dim PersonalTemp As String = "C:\Users\" & User & "\AppData\Local\Temp\"

Both return "EDUARD~1"

My friend's account is local, and when he boots up his pc, it shows "EduardoPC" in the login screen.

CodePudding user response:

dim temp = Environment.GetEnvironmentVariable("TEMP", EnvironmentVariableTarget.User) -- The directory name with ~1 is just the DOS name (8 characters max) – Jimi

Worked, thank you!

  • Related