Recently used file list c#




















The MruStripMenu class displays a list of the most recently used files in a popup menu. A derived class, MruStripMenuInline , displays them as additional entries in a menu, or inline. In both cases, a number is displayed to the left of the file. Entries allow you to use a number on the keyboard to select an entry. This is the menu item that will serve as the anchor point for the MRU list.

It must be created and inserted into the desired spot in a menu, before creating an MruMenu instance. The delegate that will be called when one of the MRU entries is selected. The entry number zero based and the filename will be passed to the handler. If a key name is passed to the constructor, and loadFromRegistry is true , MruMenu will attempt to load the files from the registry.

If the registry key does not exist, an exception will not be thrown. The maximum number of entries to allow in the MRU list. Currently, for practical reasons, the number of entries is limited to be from 4 through The maximum number of MRU entries allowed. You can set the MaxEntries to the range of 4 through If the new maximum entries is less than the current number of entries, the oldest entries will be discarded. The maximum length of the path to allow in the menu, in characters. When setting, any value less than 16 will be changed to The new length will have no effect on the current contents of the menu.

No error checking is done to verify if the key is valid. Adds the entry number prefix and mnemonic for entries to the filename. Note that the number is zero based, while the actually displayed numbering is one based. If the pathname is longer than maxLength , it replaces consecutive path components by ellipsis. It will always preserve the root of the path and at least three characters of the filename, which may cause the result to be longer than maxLength.

The pathname to check and, possibly, shorten. The pathname should be fully resolved and should start with a drive letter or be a UNC path. Find the MRU relative number of the entry which matches filename. This match must be exact except for case sensitivity.

Find the menu index of the entry which matches filename. The MRU relative number of the filename to remove. Note that this number is zero based, while the display is one based. Replaces the MRU entries with filenames. Functionally equivalent to: RemoveAll ; AddFiles filenames ;. The filenames will be added such that the first string in the array will be the topmost on the MRU list.

In other words, the entries will be added from the end to the beginning. The MRU relative number of the entry to make the first. Adds filenames to the list of files. Adds a filename to the MRU list. If the entry exists, it will be moved to the first position.

Otherwise it will be added in the first position. If the number of entries exceeds maxEntries , the least recent file the last one will be removed.

Before being added, the filename will first be resolved to an absolute path. The result will then be passed to the ShortenPathname function. Despite the absolute path resolution, it is possible for multiple entries to refer to the same physical file. Adds entryname to the MRU list and stores filename with that entry. Note that filename will be used to determine whether an entry exists. Thus it is possible to have two identical entries in the MRU list, even though the associated filenames are different.

The MRU relative number of the entry to remove. Sign in Email. Forgot your password? Search within: Articles Quick Answers Messages. Tagged as. Stats Joe Woodbury Rate me:. Please Sign up or sign in to vote. Download source - 4. The original article can be found here. When you add an item to the MRU, the method returns a uniquely identifying string, called a token, which is used to retrieve the item. You'll need the token to retrieve an item from the MRU, so persist it somewhere.

For more info about app data, see Managing application data. These entries are AccessListEntry structures that contain the token and metadata for an item.

When the MRU's item limit is reached and you try to add a new item, the item that was accessed the longest time ago is automatically removed. So, you never need to remove an item before you add a new one. As well as an MRU, your app also has a future-access list.

By picking files and folders, your user grants your app permission to access items that might not be accessible otherwise. If you add these items to your future-access list then you'll retain that permission when your app wants to access those items again later.

Your app's future-access list is represented by the StorageItemAccessList class, which you obtain from the static StorageApplicationPermissions. FutureAccessList property. Skip to main content. I am an amatuer coder, and it is tough to digest high-tech talks as of now! JumpList in WPF4 is awesome. This was all I needed to do:.

My idea of solving this problem as a beginner was to retain all the file paths into a Queue of given maximum capacity and adding them at run-time into a menuItem You could just keep a list of the documents that the user opens.

Store the list when the program exits and load it when the program launches. You could probably store a list of things in the program settings, or you could write it to a file plain text or xml would work ok. You'd have to create the submenu for "recent documents" dynamically by keeping a reference to the "recent documents" MenuItem , then adding and removing MenuItem s from its Items collection.

There's a discussion about that here: Add new menuitem to menu at runtime. The library that was linked above by Shoban looks like a set of classes that do this for you. But, it's for winforms. If you're using wpf, you might have to write your own though there are probably pre-made ones out there somewhere , but the winforms one will give you a good starting place.

LPWStr ] String pv ;. It shows how to use and implement a recent file list which is shown in the file menu and on the start page. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 11 years, 10 months ago. Active 9 years, 9 months ago.



0コメント

  • 1000 / 1000