Reputation: 1
I'm trying to make it so when this is used in anyone's PC, it uses %userprofile% instead of C:\users\Gavin to find a folder / delete a folder.. How do I go about doing so?
If MessageBox.Show("Are you sure you want to clear your cache?", "Warning!", MessageBoxButtons.YesNo) = System.Windows.Forms.DialogResult.Yes Then
If (My.Computer.FileSystem.DirectoryExists("C:\Users\Gavin\Appdata\Local\FiveM\FiveM.app\cache\")) Then
If My.Computer.FileSystem.DirectoryExists("C:\Users\Gavin\Appdata\Local\FiveM\FiveM.app\cache\browser\") Then
My.Computer.FileSystem.DeleteDirectory("C:\Users\Gavin\Appdata\Local\FiveM\FiveM.app\cache\browser\", DeleteDirectoryOption.DeleteAllContents)
End If
If My.Computer.FileSystem.DirectoryExists("C:\Users\Gavin\AppData\Local\FiveM\FiveM.app\cache\servers\") Then
My.Computer.FileSystem.DeleteDirectory("C:\Users\Gavin\AppData\Local\FiveM\FiveM.app\cache\servers\", DeleteDirectoryOption.DeleteAllContents)
End If
If My.Computer.FileSystem.DirectoryExists("C:\Users\Gavin\Appdata\Local\FiveM\FiveM.app\cache\db\") Then
My.Computer.FileSystem.DeleteDirectory("C:\Users\Gavin\Appdata\Local\FiveM\FiveM.app\cache\db\", DeleteDirectoryOption.DeleteAllContents)
End If
If My.Computer.FileSystem.DirectoryExists("C:\Users\Gavin\AppData\Local\FiveM\FiveM.app\cache\ipfs_data\") Then
My.Computer.FileSystem.DeleteDirectory("C:\Users\Gavin\Appdata\Local\FiveM\FiveM.app\cache\ipfs_data\", DeleteDirectoryOption.DeleteAllContents)
End If
If My.Computer.FileSystem.DirectoryExists("C:\Users\Gavin\Appdata\Local\FiveM\FiveM.app\cache\priv\") Then
My.Computer.FileSystem.DeleteDirectory("C:\Users\Gavin\Appdata\Local\FiveM\FiveM.app\cache\priv\", DeleteDirectoryOption.DeleteAllContents)
End If
If My.Computer.FileSystem.DirectoryExists("C:\Users\Gavin\Appdata\Local\FiveM\FiveM.app\cache\subprocess\") Then
My.Computer.FileSystem.DeleteDirectory("C:\Users\Gavin\Appdata\Local\FiveM\FiveM.app\cache\subprocess\", DeleteDirectoryOption.DeleteAllContents)
End If
If My.Computer.FileSystem.DirectoryExists("C:\Users\Gavin\Appdata\Local\FiveM\FiveM.app\cache\unconfirmed") Then
My.Computer.FileSystem.DeleteDirectory("C:\Users\Gavin\Appdata\Local\FiveM\FiveM.app\cache\unconfirmed\", DeleteDirectoryOption.DeleteAllContents)
End If
My.Computer.FileSystem.DeleteFile("C:\Users\Gavin\Appdata\Local\FiveM\FiveM.app\cache\crashometry")
My.Computer.FileSystem.DeleteFile("C:\Users\Gavin\Appdata\Local\FiveM\FiveM.app\cache\launcher_skip_mtl2")
MsgBox("Cache Deleted!")
End If
End If
End Sub```
Upvotes: 0
Views: 184
Reputation: 575
Import System.Environment
and use SpecialFolder.ApplicationData
e.g.
Dim appData As String = GetFolderPath(SpecialFolder.ApplicationData)
Upvotes: 1