本文整理汇总了C#中OpenFileDialog.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# OpenFileDialog.ShowDialog方法的具体用法?C# OpenFileDialog.ShowDialog怎么用?C# OpenFileDialog.ShowDialog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenFileDialog
的用法示例。
在下文中一共展示了OpenFileDialog.ShowDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _ouvrir
public string _ouvrir(typeFichier tf)
{
OpenFileDialog ofd = new OpenFileDialog();
if (tf == typeFichier.musique)
{
ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
ofd.Filter = "mp3 files (*.mp3)|*.mp3";
ofd.FilterIndex = 2;
ofd.RestoreDirectory = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
if (ofd.OpenFile() != null)
{
try
{
Lecteur = new Audio(ofd.FileName, false);
}
catch (Exception esx)
{
MessageBox.Show("Fichier non reconnu." + esx.HResult);
return null;
}
return ofd.FileName;
}
}
return null;
}
else if (tf == typeFichier.image)
{
ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
ofd.Filter = "JPG (*.jpg)|*.jpg";
ofd.FilterIndex = 2;
ofd.RestoreDirectory = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
try
{
if (ofd.OpenFile() != null)// On attribue le chemin du fichier à lire au
{
return ofd.FileName;
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
return null;
}
}
return null;
}
return null;
}
示例2: button1_Click
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog fileDialog = new OpenFileDialog();
//判断用户是否正确的选择了文件
if (fileDialog.ShowDialog() == DialogResult.OK)
{
FileInfo fileInfo = new FileInfo(fileDialog.FileName);
label4.Text = fileInfo.ToString();
button1.Visible = false;
string str;
StreamReader reader = new StreamReader(fileInfo.ToString(), Encoding.Default);
if ((str = reader.ReadLine()) != null)
{
string[] strArray = str.Split(new char[] { '&' });
Class1 method = new Class1();
if (strArray.Length == 3)
{
label5.Text = "CPU:" + method.Decrypto(strArray[0].ToString());
label6.Text = "磁盘:" + method.Decrypto(strArray[1].ToString());
label7.Text = "mac地址:" + method.Decrypto(strArray[2].ToString());
}
}
}
}
示例3: Template_Click
private void Template_Click(object sender, RoutedEventArgs e)
{
template_ofd = new OpenFileDialog();
template_ofd.FileName = "";
template_ofd.DefaultExt = "*.*";
template_ofd.ShowDialog();
}
示例4: Function
public void Function()
{
string strProjectpath =
PathMap.SubstitutePath("$(PROJECTPATH)") + @"\";
string strFilename = "Testdatei";
OpenFileDialog ofd = new OpenFileDialog();
ofd.DefaultExt = "txt";
ofd.FileName = strFilename;
ofd.Filter = "Testdatei (*Testdatei*.txt)"
+ "|*Testdatei*.txt|Alle Dateien (*.*)|*.*";
ofd.InitialDirectory = strProjectpath;
ofd.Title = "Testdatei auswählen:";
ofd.ValidateNames = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
strFilename = ofd.FileName;
MessageBox.Show(
"Der Speicherort wurde erfolgreich übergeben:\n"
+ strFilename,
"Information",
MessageBoxButtons.OK,
MessageBoxIcon.Information
);
}
return;
}
示例5: Screen_Click
private void Screen_Click(object sender, RoutedEventArgs e)
{
screen_ofd = new OpenFileDialog();
screen_ofd.FileName = "";
screen_ofd.DefaultExt = "*.*";
screen_ofd.ShowDialog();
}
示例6: LoadFile
private string LoadFile()
{
OpenFileDialog openFileDialog = new OpenFileDialog();
string directory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
openFileDialog.InitialDirectory = directory;
openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog.FilterIndex = 1;
openFileDialog.RestoreDirectory = true;
openFileDialog.Title = "Please Select the Shared Parameter File";
string filename = null;
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
filename = openFileDialog.FileName;
if(File.Exists(filename))
{
return filename;
}
else
{
return null;
}
}
return filename;
}
示例7: Browse_Click
private void Browse_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
System.Windows.Forms.DialogResult result = dlg.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
string filename = dlg.FileName;
FileInfo info = new FileInfo(filename);
if (!info.Exists)
{
RunButton.IsEnabled = false;
}
else
{
RunButton.IsEnabled = true;
PathBox.Text = info.FullName;
try
{
Image<Bgr, Byte> table = new Image<Bgr, byte>(info.FullName);
ImageSource bitmap = TreeViz.ToBitmapSource(table.PyrDown().PyrDown());
Shower.Source = bitmap;
}
catch (Exception ex)
{
throw ex;
}
}
}
}
示例8: btnSoundfile_Click
private void btnSoundfile_Click(object sender, System.EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if(string.Empty == PathSoundFile)
PathSoundFile = Utility.SdkMediaPath;
ofd.InitialDirectory = PathSoundFile;
ofd.Filter= "Wave files(*.wav)|*.wav";
if( DialogResult.Cancel == ofd.ShowDialog() )
return;
if(LoadSoundFile(ofd.FileName))
{
PathSoundFile = Path.GetDirectoryName(ofd.FileName);
lblFilename.Text = Path.GetFileName(ofd.FileName);
EnablePlayUI(true);
}
else
{
lblFilename.Text = "No file loaded.";
EnablePlayUI(false);
}
}
示例9: ButtonSelectFile_Click
private void ButtonSelectFile_Click(object sender, RoutedEventArgs e)
{
var dlg = new OpenFileDialog();
// Set filter for file extension and default file extension
dlg.Title = "Select csv file";
dlg.DefaultExt = ".csv";
dlg.Filter = "Text Files (.csv)|*.csv";
// Display OpenFileDialog by calling ShowDialog method
var result = dlg.ShowDialog();
// Get the selected file name and display in a TextBox
if (result == System.Windows.Forms.DialogResult.OK)
{
// Open document
var filename = dlg.FileName;
using (var sr = new StreamReader(filename, Encoding.UTF8))
{
CsvTable = new DataTable();
var csvReader = new CsvReader(sr, true);
CsvTable.Load(csvReader);
DataGridCsvTable.ItemsSource = CsvTable.DefaultView;
}
}
}
示例10: Aplikacja
//konstruktor wczytujący kalendarz z pliku
public Aplikacja()
{
kalendarz = new Kalendarz();
data = new Data_dzien();
while (data.DzienTygodnia() != DniTygodnia.poniedziałek) { data--; }
//inicjalizacja OpenFileDialog
otwórz_plik = new OpenFileDialog();
otwórz_plik.InitialDirectory = "c:\\";
otwórz_plik.FileName = "";
otwórz_plik.Filter = "pliki Kalendarza (*.kalen)|*.kalen|All files (*.*)|*.*";
otwórz_plik.FilterIndex = 2;
otwórz_plik.RestoreDirectory = true;
//**************KONIEC INICJALIZACJI OpenFileDialog**************
//inicjalizacja SaveFileDialog
zapisz_plik = new SaveFileDialog();
zapisz_plik.AddExtension = true;
zapisz_plik.FileName = "";
zapisz_plik.InitialDirectory = "c:\\";
zapisz_plik.Filter = "pliki Kalendarza (*.kalen)|*.kalen|All files (*.*)|*.*";
zapisz_plik.FilterIndex = 1;
zapisz_plik.RestoreDirectory = true;
//**************KONIEC INICJALIZACJI SaveFileDialog**************
if (otwórz_plik.ShowDialog() == DialogResult.OK)
{
Stream plik = otwórz_plik.OpenFile();
kalendarz.Wczytaj(plik);
plik.Flush();
plik.Close();
}
}
示例11: Start
// Use this for initialization
void Start()
{
loadingText = GameObject.Find("LoadingText").GetComponent<Text>();
//BMSE Argument
string[] args = Environment.GetCommandLineArgs();
if(args.Length != 0)
{
Debug.Log(args[args.Length - 1]);
path = args[args.Length - 1];
if (File.Exists(path))
{
StartCoroutine("LoadMain");
return;
}
}
//Open without argument
while (!File.Exists(path))
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "BMS Files|*.bms;*.bme;*.bml;*.pms";
openFileDialog.Title = "Select a BMS File";
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
path = openFileDialog.FileName;
}
}
StartCoroutine("LoadMain");
}
示例12: LoadPlugin_Click
private void LoadPlugin_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Plugins (*.dll)|*.dll|All Files (*.*)|*.*";
if (ofd.ShowDialog() != DialogResult.Cancel)
host.Project.LoadAssembly(Assembly.LoadFile(ofd.FileName), true);
}
示例13: ButtonAddPhoto_Click
private void ButtonAddPhoto_Click(object sender, RoutedEventArgs e)
{
FullGrid.Visibility = Visibility.Hidden;
AnimationLoading.Visibility = Visibility.Visible;
var dlg = new OpenFileDialog
{
InitialDirectory = @"c:\\",
Filter = @"Image files (*.jpg)|*.jpg",
RestoreDirectory = true
};
var bitmap = new BitmapImage();
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
_filepath = dlg.FileName;
bitmap.BeginInit();
bitmap.UriSource = new Uri(_filepath);
bitmap.EndInit();
_hashfile = AppDomain.CurrentDomain.BaseDirectory + @"Temp\" + @"Visit\" + _i + @".jpg";
File.Copy(_filepath, _hashfile);
Picture.CollectionLoadPhoto.Add(new Picture(new BitmapImage(new Uri(_filepath)), _i + @".jpg"));
_i++;
ListBoxPhoto.ItemsSource = Picture.CollectionLoadPhoto;
ListBoxPhoto.Visibility = Visibility.Visible;
}
AnimationLoading.Visibility = Visibility.Hidden;
FullGrid.Visibility = Visibility.Visible;
}
示例14: butJavawBrowse_Click
private void butJavawBrowse_Click(object sender, RoutedEventArgs e)
{
FileDialog dialog = new OpenFileDialog();
dialog.Filter = "javaw.exe | javaw.exe";
dialog.ShowDialog();
comboJava.Text = dialog.FileName;
}
示例15: databind
public void databind()
{
cboxLoadOnStartup.IsChecked = this.ApplicationSettings.LoadOnStartUp;
cboxStartMinimized.IsChecked = this.ApplicationSettings.StartMinimized;
cboxCheckForUpdates.IsChecked = this.ApplicationSettings.CheckForUpdates;
//
this.cboxLanguages_databind();
//
txtBrowser.Text = this.ApplicationSettings.BrowserFileInfo.FullName;
btnBrowseBrowser.Click += delegate(object sender, RoutedEventArgs e) {
FileDialog fDialog = new OpenFileDialog();
DialogResult dResult = fDialog.ShowDialog();
if (dResult == DialogResult.OK) {
this.ApplicationSettings.BrowserFileInfo = new FileInfo(fDialog.FileName);
txtBrowser.Text = this.ApplicationSettings.BrowserFileInfo.FullName;
}
};
//
txtTempFolder.Text = this.ApplicationSettings.TempDirectory.FullName;
btnBrowseTempFolder.Click += delegate(object sender, RoutedEventArgs e) {
FolderBrowserDialog fBrowser = new FolderBrowserDialog();
DialogResult dResult = fBrowser.ShowDialog();
if (dResult == DialogResult.OK) {
this.ApplicationSettings.TempDirectory = new DirectoryInfo(fBrowser.SelectedPath);
txtTempFolder.Text = this.ApplicationSettings.TempDirectory.FullName;
}
};
}