1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

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

Discussion in 'Software Development' started by sandycrush, Dec 28, 2009.

Thread Status:
Not open for further replies.
  1. sandycrush

    sandycrush Thread Starter

    Joined:
    Dec 28, 2009
    Messages:
    1
    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.
     
  2. peterh40

    peterh40

    Joined:
    Apr 15, 2007
    Messages:
    1,396
    First Name:
    Peter
    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
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/888966

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice