beginner question

Discussion in 'Visual Basic .NET' started by Nickel, Dec 29, 2011.

  1. Nickel

    Nickel Regular Member

    Joined:
    Dec 24, 2010
    Messages:
    217
    Likes Received:
    127
    Location:
    Yes
    I have an app I am making and I need it to check for and delete a file from the folder it was launched from but not sure how to get the path for that.

    I have it sucessfully cleaning up files from temp folder like this

    Code:
     
    If IO.File.Exists(Environ("temp") & "/update.exe") Then
    IO.File.Delete(Environ("temp") & "/update.exe")
    how can I do the same thing to delete a file from the application startup folder?
     
  2. smack

    smack Junior Member

    Joined:
    Feb 1, 2010
    Messages:
    182
    Likes Received:
    80
    Occupation:
    Software Engineer/Evil Genius
    Location:
    inside .NET
    Application.StartupPath

    Code:
    http://msdn.microsoft.com/en-us/library/system.windows.forms.application.startuppath.aspx
     
  3. Nickel

    Nickel Regular Member

    Joined:
    Dec 24, 2010
    Messages:
    217
    Likes Received:
    127
    Location:
    Yes
    Hi, thx for reply smack
    I had already found this much

    Application Executable Path:
    Dim FolderName As String = Application.StartupPath

    so I assumed you just enter that line of code somewhere on the script and then this would work

    If IO.File.Exists(Environ("Application.StartupPath ") & "/update.exe") Then
    IO.File.Delete(Environ("Application.StartupPath ") & "/update.exe")

    ..or just "StartupPath"
    tried both and neither worked - can you tell me how to use this correctly?
     
  4. shubhamm

    shubhamm Junior Member

    Joined:
    Jan 25, 2010
    Messages:
    128
    Likes Received:
    29
    Occupation:
    Developer
    Location:
    BHW
    PHP:
    If IO.File.Exists(Application.StartupPath "/update.exe"Then
    IO
    .File.Delete(Application.StartupPath "/update.exe")