本文整理汇总了C#中System.Windows.Forms.FolderBrowserDialog类的典型用法代码示例。如果您正苦于以下问题:C# System.Windows.Forms.FolderBrowserDialog类的具体用法?C# System.Windows.Forms.FolderBrowserDialog怎么用?C# System.Windows.Forms.FolderBrowserDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Windows.Forms.FolderBrowserDialog类属于命名空间,在下文中一共展示了System.Windows.Forms.FolderBrowserDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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
});
}
}
示例4: 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);
}
示例5: 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;
}
示例6: btnInputFolder_Click
private void btnInputFolder_Click(object sender, RoutedEventArgs e)
{
System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
if (Directory.Exists(txtInputFolder.Text))
fbd.SelectedPath = txtInputFolder.Text;
else
fbd.SelectedPath = Helpers.VariousFunctions.GetApplicationLocation();
if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
GeneratorMaps.Clear();
txtInputFolder.Text = fbd.SelectedPath;
DirectoryInfo di = new DirectoryInfo(txtInputFolder.Text);
FileInfo[] fis = di.GetFiles("*.map");
foreach (FileInfo fi in fis)
{
GeneratorMaps.Add(new MapEntry()
{
IsSelected = true,
LocalMapPath = fi.FullName,
MapName = fi.Name
});
}
}
}
示例7: addSavePath
public bool addSavePath(AWindow window)
{
string new_path;
System.Windows.Forms.FolderBrowserDialog folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
folderBrowser.ShowNewFolderButton = true;
folderBrowser.Description = Strings.GetLabelString("SelectAltPath");
bool try_again = false;
do {
if (folderBrowser.ShowDialog(window.GetIWin32Window()) == System.Windows.Forms.DialogResult.OK) {
new_path = folderBrowser.SelectedPath;
if (PermissionsHelper.isReadable(new_path)) {
if (Core.settings.addSavePath(new_path)) {
try_again = false;
return true;
} else {
this.showTranslatedError("SelectAltPathDuplicate");
try_again = true;
}
} else {
this.showTranslatedError("SelectAltPathDuplicate");
try_again = true;
}
} else {
try_again = false;
}
} while (try_again);
return false;
}
示例8: BrowseForFolder
public static string BrowseForFolder(string startingPath)
{
string initialDirectory = _lastDirectory ?? startingPath;
string ret = null;
try
{
var cfd = new CommonOpenFileDialog
{
InitialDirectory = initialDirectory,
IsFolderPicker = true
};
if (cfd.ShowDialog() == CommonFileDialogResult.Ok)
{
ret = cfd.FileName;
}
}
catch (System.PlatformNotSupportedException)
{
var fd = new System.Windows.Forms.FolderBrowserDialog
{
SelectedPath = initialDirectory
};
if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
ret = fd.SelectedPath;
}
}
_lastDirectory = ret;
return ret;
}
示例9: InitializeComponent
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// folderBrowserDialog1
//
this.folderBrowserDialog1.Description = "Chose monitor fodler";
//
// button1
//
this.button1.Location = new System.Drawing.Point(100, 54);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(186, 78);
this.button1.TabIndex = 0;
this.button1.Text = "chose monitor folder";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.Button1Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(396, 264);
this.Controls.Add(this.button1);
this.Name = "MainForm";
this.Text = "LoseAV";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainFormFormClosing);
this.ResumeLayout(false);
}
示例10: SetMode
private void SetMode()
{
if(IsFileSelector)
{
ButtonText = "\uF15C";
ButtonCommand = new RelayCommand(() =>
{
var dlg = new OpenFileDialog();
if (dlg.ShowDialog() == true)
{
ConfigItemValue = dlg.FileName;
}
}, true);
}
else
{
ButtonText = "\uF07C";
ButtonCommand = new RelayCommand(() =>
{
var dlg = new System.Windows.Forms.FolderBrowserDialog();
dlg.ShowNewFolderButton = true;
dlg.ShowDialog();
if (!String.IsNullOrEmpty(dlg.SelectedPath))
{
ConfigItemValue = dlg.SelectedPath;
}
}, true);
}
}
示例11: brouse_Click
private void brouse_Click(object sender, RoutedEventArgs e)
{
dlg = new System.Windows.Forms.FolderBrowserDialog();
result = dlg.ShowDialog(this.GetIWin32Window());
if (result == System.Windows.Forms.DialogResult.OK)
pathLabel.Content = dlg.SelectedPath;
}
示例12: 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();
});
});
}
}
示例13: 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;
}
示例14: btnNewBase_Click
private void btnNewBase_Click(object sender, RoutedEventArgs e)
{
string path;
var dialog = new System.Windows.Forms.FolderBrowserDialog();
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
if (result.ToString() == "OK")
{
path = dialog.SelectedPath;
}
else
path = null;
if (path != null)
{
try
{
DataBaseConfig.CreateNewDB(path);
}
catch (Exception ex)
{
MessageBox.Show("Ошибка создания базы!\n\n" + ex.Message);
return;
}
MessageBox.Show("База успешно создана и подключена!!");
}
}
示例15: FolderBrowserEditor_Loaded
private void FolderBrowserEditor_Loaded(object sender, RoutedEventArgs e)
{
FolderBrowserDialog folderBrowser;
Popup parentPopup;
Dictionary<string, string> settings;
string setting;
// Set up folder browser
folderBrowser = new FolderBrowserDialog();
folderBrowser.SelectedPath = GetCurrentParameterValue();
// Parse folder browser parameters if they have been defined
if ((object)m_connectionString != null)
{
settings = m_connectionString.ParseKeyValuePairs();
if (settings.TryGetValue("description", out setting))
folderBrowser.Description = setting;
if (settings.TryGetValue("showNewFolderButton", out setting))
folderBrowser.ShowNewFolderButton = setting.ParseBoolean();
}
// Show the browser and update the parameter
if (folderBrowser.ShowDialog() == System.Windows.Forms.DialogResult.OK)
UpdateParameterValue(folderBrowser.SelectedPath);
// Close the popup that contains this control
parentPopup = GetParentPopup();
if ((object)parentPopup != null)
parentPopup.IsOpen = false;
}