本文整理汇总了C#中System.Windows.Forms.FolderBrowserDialog.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# System.Windows.Forms.FolderBrowserDialog.ShowDialog方法的具体用法?C# System.Windows.Forms.FolderBrowserDialog.ShowDialog怎么用?C# System.Windows.Forms.FolderBrowserDialog.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.FolderBrowserDialog
的用法示例。
在下文中一共展示了System.Windows.Forms.FolderBrowserDialog.ShowDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChooseDirectory_Click
/// <summary>
/// Choosing directory handler
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ChooseDirectory_Click(object sender, RoutedEventArgs e)
{
var dialog = new System.Windows.Forms.FolderBrowserDialog();
dialog.ShowDialog();
dirBlock.Text = dialog.SelectedPath;
if (dialog.SelectedPath != "")
{
while (!(Directory.EnumerateFiles(dialog.SelectedPath).Any() && Directory.EnumerateDirectories(dialog.SelectedPath).Any()) && dialog.SelectedPath != "")
{
System.Windows.MessageBox.Show("Please do not choose an empty folder for sharing");
dialog.ShowDialog();
dirBlock.Text = dialog.SelectedPath;
}
}
}
示例2: btnDir3_Click
//pull up the modal box to select directory on click
private void btnDir3_Click(object sender, RoutedEventArgs e)
{
var dialog = new System.Windows.Forms.FolderBrowserDialog();
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
txt3.Text = dialog.SelectedPath;
}
示例3: viewFolderButton_Click
// method adds a folder into the location box,
// then adds all the erfs in all subfolders into the list of erfs
private void viewFolderButton_Click(object sender, RoutedEventArgs e)
{
System.Windows.Forms.FolderBrowserDialog browser = new System.Windows.Forms.FolderBrowserDialog();
browser.ShowNewFolderButton = false;
System.Windows.Forms.DialogResult result = browser.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
//User clicked OK, add the path into the location box, try to add all the erfs in there too
if (!ResourceManager.filePaths.Contains(browser.SelectedPath))
{
ResourceManager.addFilePath(browser.SelectedPath);
}
locationListBox.Items.Add(browser.SelectedPath);
foreach (String s in Directory.GetDirectories(browser.SelectedPath, "*", SearchOption.AllDirectories))
{
if (!ResourceManager.filePaths.Contains(s))
{
//Add all the subdirectories
ResourceManager.addFilePath(s);
}
}
foreach (String t in Directory.GetFiles(browser.SelectedPath, "*.erf", SearchOption.AllDirectories))
{
ResourceManager.addERF(t);
}
}
}
示例4: CreateContent
public UIElement CreateContent(string directoryName)
{
Grid grid_main = new Grid();
grid_main.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(100.0, GridUnitType.Star) });
grid_main.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
m_textBox_directoryName = new TextBox();
m_textBox_directoryName.TextChanged += (sender, args) => { DirectoryName = m_textBox_directoryName.Text; };
m_textBox_directoryName.Text = directoryName;
grid_main.SetGridRowColumn(m_textBox_directoryName, 0, 0);
Button button_openFile = new Button() { Content = "Select directory ..." };
button_openFile.Click += (x, y) =>
{
System.Windows.Forms.FolderBrowserDialog selectDirectoryDialog =
new System.Windows.Forms.FolderBrowserDialog()
{
SelectedPath = directoryName
};
if (selectDirectoryDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
m_textBox_directoryName.Text = selectDirectoryDialog.SelectedPath;
};
grid_main.SetGridRowColumn(button_openFile, 0, 1);
return grid_main;
}
示例5: OnStartup
protected override void OnStartup(StartupEventArgs e)
{
var prefs = IoC.Get<IAppPreferences>();
prefs.Load();
if (string.IsNullOrEmpty(prefs.DataStorePath))
{
System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
fbd.Description = "Choose location for BrainLab data store. The study database, subject files, and reports will be stored in this location.";
// Show open file dialog box
System.Windows.Forms.DialogResult result = fbd.ShowDialog();
// Process open file dialog box results
if (result == System.Windows.Forms.DialogResult.OK)
{
prefs.DataStorePath = fbd.SelectedPath;
}
else
System.Windows.Application.Current.Shutdown();
}
base.OnStartup(e);
}
示例6: Run
public void Run()
{
System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
folderDialog.ShowNewFolderButton = true;
if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
WaitWindow waitWindow = new WaitWindow("Importing collection...");
waitWindow.ShowDialog(this.ParentWindow, () =>
{
try
{
using (DirectoryCollectionImporter importer = new DirectoryCollectionImporter(folderDialog.SelectedPath, this.CollectionManager))
{
importer.Import();
}
}
catch (Exception ex)
{
Utility.WriteToErrorLog("Error importing: " + ex.ToString());
MessageBox.Show("Error importing backup: " + ex.Message);
}
this.ParentWindow.Dispatcher.BeginInvokeAction(() =>
{
CollectionManagerGlobal.OnCollectionChanged();
});
});
}
}
示例7: btnSelectFiles_Click
private void btnSelectFiles_Click(object sender, RoutedEventArgs e)
{
System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
System.Windows.Forms.DialogResult result = fbd.ShowDialog();
tbSelectedPath.Text = fbd.SelectedPath;
}
示例8: MediaPlayer_VlcLibDirectoryNeeded
private void MediaPlayer_VlcLibDirectoryNeeded(object sender, Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs e)
{
var currentAssembly = Assembly.GetEntryAssembly();
var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
if (currentDirectory == null)
return;
if (AssemblyName.GetAssemblyName(currentAssembly.Location).ProcessorArchitecture == ProcessorArchitecture.X86)
e.VlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, @"vlc\x86\"));
//e.VlcLibDirectory = new DirectoryInfo(currentDirectory);
else
e.VlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, @"vlc\x64\"));
//e.VlcLibDirectory = new DirectoryInfo(currentDirectory);
if (!e.VlcLibDirectory.Exists)
{
var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
folderBrowserDialog.Description = "Select Vlc libraries folder.";
folderBrowserDialog.RootFolder = Environment.SpecialFolder.Desktop;
folderBrowserDialog.ShowNewFolderButton = true;
if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
e.VlcLibDirectory = new DirectoryInfo(folderBrowserDialog.SelectedPath);
}
}
}
示例9: Button_Click_1
private void Button_Click_1(object sender, RoutedEventArgs e)
{
var dialog = new System.Windows.Forms.FolderBrowserDialog();
dialog.SelectedPath = Environment.CurrentDirectory;
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
workFolderTB.Text = dialog.SelectedPath;
}
示例10: MainWindow
public MainWindow()
{
Boolean bFirst = true;
string sSelectedItem = "";
InitializeComponent();
//Open folder dialog
System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
fbd.Description = "Please, select the folder which contains your stock market data files.";
System.Windows.Forms.DialogResult drResult = fbd.ShowDialog();
sLocation = fbd.SelectedPath;
while (fbd.SelectedPath == "")
{
fbd = new System.Windows.Forms.FolderBrowserDialog();
fbd.Description = "You have to choose the folder which contains your stock market data files before you continue!";
drResult = fbd.ShowDialog();
sLocation = fbd.SelectedPath;
}
//Loading all .csv files into the combo box
foreach (string stock in Directory.EnumerateFiles(fbd.SelectedPath, "*.csv"))
{
string stockName = stock.Substring(stock.LastIndexOf("\\") + 1, stock.Length - (stock.LastIndexOf("\\") + 1) - 4);
cboStock.Items.Add(stockName);
//Load the first file - optional...can work without setting the SelectedItem...everything below may be omitted
if (bFirst)
{
sSelectedItem = stockName;
bFirst = false;
}
}
cboStock.SelectedItem = sSelectedItem;
}
示例11: btnInputFolder_Click
private void btnInputFolder_Click(object sender, RoutedEventArgs e)
{
var fbd = new System.Windows.Forms.FolderBrowserDialog
{
SelectedPath =
Directory.Exists(txtInputFolder.Text)
? txtInputFolder.Text
: Helpers.VariousFunctions.GetApplicationLocation()
};
if (fbd.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
GeneratorMaps.Clear();
txtInputFolder.Text = fbd.SelectedPath;
var di = new DirectoryInfo(txtInputFolder.Text);
var fis = di.GetFiles("*.map");
foreach (var fi in fis.Where(fi => !fi.Name.ToLower().StartsWith("campaign") && !fi.Name.ToLower().StartsWith("shared") && !fi.Name.ToLower().StartsWith("single_player_shared")))
{
GeneratorMaps.Add(new MapEntry
{
IsSelected = true,
LocalMapPath = fi.FullName,
MapName = fi.Name
});
}
}
示例12: changeSyncPath
public bool changeSyncPath()
{
string old_path = Core.settings.sync_path;
string new_path = null;
System.Windows.Forms.FolderBrowserDialog folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
folderBrowser.ShowNewFolderButton = true;
folderBrowser.Description = "Choose where the saves will be synced.";
folderBrowser.SelectedPath = old_path;
bool try_again = false;
do {
if (folderBrowser.ShowDialog(this.GetIWin32Window()) == System.Windows.Forms.DialogResult.OK) {
new_path = folderBrowser.SelectedPath;
if (PermissionsHelper.isReadable(new_path)) {
if (PermissionsHelper.isWritable(new_path)) {
Core.settings.sync_path = new_path;
if (new_path != old_path)
Core.rebuild_sync = true;
return new_path != old_path;
} else {
this.displayError("Config File Error", "You don't have permission to write to the selected sync folder:" + Environment.NewLine + new_path);
try_again = true;
}
} else {
this.displayError("Config File Error", "You don't have permission to read from the selected sync folder:" + Environment.NewLine + new_path);
try_again = true;
}
} else {
try_again = false;
}
} while (try_again);
return false;
}
示例13: BrowseFolder_Button_Click
private void BrowseFolder_Button_Click(object sender, RoutedEventArgs e)
{
var dialog = new System.Windows.Forms.FolderBrowserDialog();
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
string FolderName = dialog.SelectedPath;
SelectFolder(FolderName);
}
示例14: changeConfigFolder
public static bool changeConfigFolder(Window parent, ASettings settings, string setting_name,
string description, string error_message, Permissions required_permissions) {
string old_path = settings.get(setting_name);
string new_path = null;
System.Windows.Forms.FolderBrowserDialog folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
folderBrowser.ShowNewFolderButton = true;
folderBrowser.Description = description;
folderBrowser.SelectedPath = old_path;
bool try_again = false;
do {
if (folderBrowser.ShowDialog(GetIWin32Window(parent)) == System.Windows.Forms.DialogResult.OK) {
new_path = folderBrowser.SelectedPath;
if (PermissionsHelper.isReadable(new_path)) {
if (required_permissions < Permissions.Write
||PermissionsHelper.isWritable(new_path)) {
settings.set(setting_name, new_path);
return new_path != old_path;
} else {
folderBrowser.Description = error_message;
try_again = true;
}
} else {
folderBrowser.Description = error_message;
try_again = true;
}
} else {
try_again = false;
}
} while (try_again);
return false;
}
示例15: AskForInstallDirectory
private string AskForInstallDirectory()
{
MessageBox.Show("Since this is the first time the Mod Manager has been run, you need to choose the directory that Cortex Command is installed to.", "First Time", MessageBoxButton.OK, MessageBoxImage.Information);
while (true)
{
var browser = new System.Windows.Forms.FolderBrowserDialog();
browser.Description = "Choose the install location for Cortex Command";
browser.ShowNewFolderButton = false;
browser.RootFolder = Environment.SpecialFolder.MyComputer;
var result = browser.ShowDialog();
if (result != System.Windows.Forms.DialogResult.OK)
return null; //The user cancelled the choosing.
var installDirectory = browser.SelectedPath;
if (CortexCommand.IsInstalledTo(installDirectory))
return installDirectory;
MessageBox.Show("The directory you chose does not have a valid Cortex Command installation in it. Please choose the folder where Cortex Command is installed.",
"Incorrect Folder", MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
}