Free Code Snippets in C#, Net Framework, Office 365, ASP.Net,WPF, Visual Studio, SQL Server, Antivirus free
#

UWP: Open the file Explorer from a Windows app

 

I would like to start the file Explorer from my Windows 10 app and do open a folder whose path I want to pass at boot.

(UWP, universal Windows platform application)

 

Solution:

To do this, use the Launcher in window 10. The Launcher can open files, directories, search results and Web paths.

About Launcher. LaunchFolderAsync (folder) can open a directory object to display.

So that you can pass a directory, you must this previously with Storagefolder. Determine GetFolderFromPathAsync(Path) .

        private async void menuItem_Open_Explorer (object sender, RoutedEventArgs e)

        {

            -< menuItem_Open_Explorer() > -.

            < get folder >

            string sPath path; =

            StorageFolder folder = await StorageFolder. GetFolderFromPathAsync(sPath);

            < / get folder >

 

            < open file Explorer >

            await Launcher. LaunchFolderAsync(folder);

            < / open file Explorer >

            -< / menuItem_Open_Explorer() > -.

        }

 

For this purpose, the namespaces are needed for the folder and the Launcher:

using Windows.System; //Launcher

using Windows.Storage; //Files File.AccessMode

 

 

For example I start that open Explorer event with a flyout menu. This starts the Click Event -> menuItem_open_Explorer

        <TextBlock x : Name = "ctlTitel" Grid.Column "1" = Text = "Folder" FontFamily = "Arial" FontSize = "14" TextTrimming = "Clip" TextWrapping = "Wrap" IsTextSelectionEnabled = "True" VerticalAlignment "Center" Margin= "3,0,0,0"

                IsHitTestVisible = "True" RightTapped = "ctlTitel_RightTapped"  >

            <FlyoutBase.AttachedFlyout >

                <MenuFlyout x : Name = "menuFolderTitle" Placement = 'Right'  >

                    <MenuFlyoutItem Text FlowDirection= "LeftToRight" = "open Explorer" click= "menuItem_Open_Explorer"> < /MenuFlyoutItem>                   

                </MenuFlyout>

            </FlyoutBase.AttachedFlyout>

        </TextBlock>

 

The open Explorer context menu to trigger the event

 

 

It follows that the file Explorer as a separate application is started

And thereby open the specified folder

 

as video tutorial

 

Mobile
»
UWP: Selectionbox Usercontrol
»
UWP: Microsoft has important functions only for Microsoft and partners
»
UWP: AutoPlay properly set the field [content event]
»
UWP, c#: Get Image properties
»
UWP, c#: Properties determine video
»
UWP: determine the file size of a Storagefile
»
UWP, SQLite: SQLite code to create a database, the tables and indexes
»
UWP: C# Code to copy several files to the Clipboard
»
UWP, WPF: C# code to search a parent control in XAML Structure
»
UWP: Copy a single file to the Clipboard with unknown filetype

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de