Ive wrote a small program to open at startup, but i want to give the user a chance to delete it from showing on startup by clicking a button. But it needs to be compatible on XP, Vista and Windows 7. Is there a line of code which will get the default startup folder path automatically so i can then delete it using my button?

Thankyou in advance,

Ross

What path are you trying to get? The application's startup path?

Dim myStartupFolderPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup)

cheers guys. I found it elsewhere. here is the code i used if anyone needs it

Dim startupfolder As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup)
        Dim path As String = startupfolder & "\" & "testing.txt"

        Try
            If System.IO.File.Exists(path) = True Then

                System.IO.File.Delete(path)
                MsgBox("File Deleted")
            Else
                MsgBox("File Not Deleted")
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
commented: thanks for provided solution:) +12
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.