I've written a small 开发者_开发技巧program to open at startup, but I want to give the user the ability 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?
Thank you in advance
What you are wanting is the SpecialFolder.Enumeration. and use the Environment methods
Something like this Environment.GetFolderPath(Environment.SpecialFolder.Startup)
To do your deletion you need to use System.IO.File.Delete(path)
To check to see what files are out there try making a console application and use this code.
Module Module1
Sub Main()
Dim path As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup)
For Each file In System.IO.Directory.GetFiles(path)
Console.WriteLine(file)
Next
Console.ReadLine()
End Sub
End Module
精彩评论