# How to access Current User profile application data to delete a file in it in VB



## sandycrush (Dec 28, 2009)

Hi guyz,


Please provide me a sample code as how to access Current Logged in User profile application data and how to delete a file in application data folder using vb code. I am very new to this technology pls help me.


----------



## peterh40 (Apr 15, 2007)

Here's the code in VB .Net 2008:

Public Class RemoveFileFromProfile

Private Sub cmd_DelFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_DelFile.Click
Dim profile As String, fullpath As String
Dim filename As String

' Environment variables
' USERPROFILE = Path to current user profile
' APPDATA = Path to application data in current profile

profile = Environ("APPDATA")
filename = txt_Fname.Text
fullpath = profile & "\" & filename
 FileSystem.Kill(fullpath)
MsgBox(filename & " deleted.")

End Sub
End Class


----------

