using Microsoft.Win32; OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == true) { MessageBox.Show("Selected file: " + openFileDialog.FileName); }
using Microsoft.Win32; OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Multiselect = true; if (openFileDialog.ShowDialog() == true) { foreach (string fileName in openFileDialog.FileNames) { listBox.Items.Add(fileName); } }
using Microsoft.Win32; OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); if (openFileDialog.ShowDialog() == true) { MessageBox.Show("Selected file: " + openFileDialog.FileName); }The Microsoft.Win32 namespace is part of the .NET Framework, which is a package library provided by Microsoft for developing Windows applications in C#. The OpenFileDialog is one of many classes in this library that can be used to interact with the Windows operating system.