I have a folder with .txt files in it. How can i make my menuitem get those .tx开发者_如何学JAVAt files and put the filenames in the menuitem, so that it creates a list of all .txt files in that folder.
So when i put a .txt in the folder the program automatically creates the menu item.
Does someone knows how to do this, or perhaps an example?
Unless you're using ASP.Net, you're looking for the FileSystemWatcher
and Directory
classes.
Basically, you need to call Directory.GetFiles
and loop through the results creating MenuItems.
Then, handle the FileSystemWatcher
events and either rebuild the menu from scratch (simpler) or update the appropriate item (faster)
精彩评论