VB正在AppData文件夹中删除



我正在努力让它在任何人的电脑中使用时,它都会使用%userprofile%而不是C:\users\Gavin来查找文件夹/删除文件夹。。我该怎么做?

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:UsersGavinAppdataLocalFiveMFiveM.appcache")) Then
If My.Computer.FileSystem.DirectoryExists("C:UsersGavinAppdataLocalFiveMFiveM.appcachebrowser") Then
My.Computer.FileSystem.DeleteDirectory("C:UsersGavinAppdataLocalFiveMFiveM.appcachebrowser", DeleteDirectoryOption.DeleteAllContents)
End If
If My.Computer.FileSystem.DirectoryExists("C:UsersGavinAppDataLocalFiveMFiveM.appcacheservers") Then
My.Computer.FileSystem.DeleteDirectory("C:UsersGavinAppDataLocalFiveMFiveM.appcacheservers", DeleteDirectoryOption.DeleteAllContents)
End If
If My.Computer.FileSystem.DirectoryExists("C:UsersGavinAppdataLocalFiveMFiveM.appcachedb") Then
My.Computer.FileSystem.DeleteDirectory("C:UsersGavinAppdataLocalFiveMFiveM.appcachedb", DeleteDirectoryOption.DeleteAllContents)
End If
If My.Computer.FileSystem.DirectoryExists("C:UsersGavinAppDataLocalFiveMFiveM.appcacheipfs_data") Then
My.Computer.FileSystem.DeleteDirectory("C:UsersGavinAppdataLocalFiveMFiveM.appcacheipfs_data", DeleteDirectoryOption.DeleteAllContents)
End If
If My.Computer.FileSystem.DirectoryExists("C:UsersGavinAppdataLocalFiveMFiveM.appcachepriv") Then
My.Computer.FileSystem.DeleteDirectory("C:UsersGavinAppdataLocalFiveMFiveM.appcachepriv", DeleteDirectoryOption.DeleteAllContents)
End If
If My.Computer.FileSystem.DirectoryExists("C:UsersGavinAppdataLocalFiveMFiveM.appcachesubprocess") Then
My.Computer.FileSystem.DeleteDirectory("C:UsersGavinAppdataLocalFiveMFiveM.appcachesubprocess", DeleteDirectoryOption.DeleteAllContents)
End If
If My.Computer.FileSystem.DirectoryExists("C:UsersGavinAppdataLocalFiveMFiveM.appcacheunconfirmed") Then
My.Computer.FileSystem.DeleteDirectory("C:UsersGavinAppdataLocalFiveMFiveM.appcacheunconfirmed", DeleteDirectoryOption.DeleteAllContents)
End If
My.Computer.FileSystem.DeleteFile("C:UsersGavinAppdataLocalFiveMFiveM.appcachecrashometry")
My.Computer.FileSystem.DeleteFile("C:UsersGavinAppdataLocalFiveMFiveM.appcachelauncher_skip_mtl2")
MsgBox("Cache Deleted!")
End If
End If
End Sub```

导入System.Environment并使用SpecialFolder.ApplicationData,例如

Dim appData As String = GetFolderPath(SpecialFolder.ApplicationData)

最新更新