private void mInsertOnClick(object sender, EventArgs ea) { //insert file OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Select file"; ofd.Filter = "All Files (*.*)|*.*|Dll Files (*.dll)|*.dll"; if (ofd.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; FileInfo fi = new FileInfo(ofd.FileName); ListViewFileItem lvi = new ListViewFileItem(); lvi.Text = Path.GetFileName(ofd.FileName); lvi.SubItems.Add("Yes"); lvi.SubItems.Add("No"); lvi.SubItems.Add("No"); lvi.SubItems.Add(fi.Length.ToString("n0")); lvi.Offset = 0; lvi.Size = (int)fi.Length; lvi.SubItems.Add(Path.GetFullPath(ofd.FileName)); if (contents.SelectedItems.Count == 0) { //no items selected so add at bottom contents.Items.Add(lvi); } else { //insert before first selected item contents.Items.Insert(contents.SelectedItems[0].Index, lvi); } //check for _virtual.dat if (lvi.Text == "_virtual.dat") { //get display settings from _virtual.dat FileStream fsIn = null; BinaryReader brIn = null; try { fsIn = new FileStream(ofd.FileName, FileMode.Open); brIn = new BinaryReader(fsIn); displayMode = brIn.ReadInt32(); displayWidth = brIn.ReadInt32(); displayHeight = brIn.ReadInt32(); displayDepth = brIn.ReadInt32(); contents.ContextMenu.MenuItems[0].Text = proExe.getDisplayString(displayWidth, displayHeight, displayDepth, displayMode); contents.ContextMenu.MenuItems[0].Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { brIn.Close(); fsIn.Close(); } } Cursor.Current = Cursors.Default; } ofd.Dispose(); //enable menu items if (contents.Items.Count > 0) { contents.ContextMenu.MenuItems[2].Enabled = true; //save contents.ContextMenu.MenuItems[11].MenuItems[0].Enabled = true; //decompress } }
public void Dispose() { openFileDialog?.Dispose(); saveFileDialog?.Dispose(); exportFileDialog?.Dispose(); importFileDialog?.Dispose(); }
private void btnUpload_Click(object sender, EventArgs e) { OpenFileDialog fileDialog = null; UploadEeClient eeClient = null; try { // Выбираем файл fileDialog = new OpenFileDialog(); var dialogResult = fileDialog.ShowDialog(); if (dialogResult != DialogResult.OK || fileDialog.FileNames.Length == 0 || string.IsNullOrEmpty(fileDialog.FileNames[0])) { return; } // Загружаем файл eeClient = new UploadEeClient(); tbDownloadLink.Text = eeClient.UploadFile(fileDialog.FileNames[0]); } catch (Exception ex) { MessageBox.Show("Ошибка: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { // Убираем за собой мусор fileDialog?.Dispose(); eeClient?.Dispose(); } }
public FileManager() { this.m_BasePath = Application.StartupPath; this.m_FilePath = Engine.m_OverrideDataPath; if (this.m_FilePath == null) { this.m_FilePath = this.GetExePath("Ultima Online"); if (this.m_FilePath == null) { this.m_FilePath = this.GetExePath("Ultima Online Third Dawn"); if (this.m_FilePath == null) { OpenFileDialog dialog = new OpenFileDialog { CheckPathExists = true, CheckFileExists = false, FileName = "Client.exe", Filter = "Client.exe|Client.exe", Title = "Find your UO directory", InitialDirectory = Path.GetPathRoot(this.m_BasePath) }; if (dialog.ShowDialog() == DialogResult.OK) { this.m_FilePath = Path.GetDirectoryName(dialog.FileName); } else { MessageBox.Show("Couldn't find UO directory.", "Client"); } dialog.Dispose(); } } this.m_Error = this.m_FilePath == null; } }
private void DisposeAddedComponents() { folderPicker?.Dispose(); filePicker?.Dispose(); folderPicker = null; filePicker = null; }
private void SelectPicture_Click(object sender, EventArgs e) { OpenFileDialog openfile = new OpenFileDialog(); if(openfile.ShowDialog()==DialogResult.OK&&(openFileDialog1.FileName!="")) { pictureBox.ImageLocation = openfile.FileName; textPath.Text = openfile.FileName; } openfile.Dispose(); }
public static string ShowOpenProjectDialog <T>(ref T project) where T : BaseProject, new() { T loadedProject = new T(); string projectTypeName = GetTypeName <T>(); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = string.Format( "{0} (*.{1})|*.{2}|All files (*.*)|*.*", projectTypeName, loadedProject.ProjectFormat?.ToUpper() ?? string.Empty, loadedProject.ProjectFormat ?? string.Empty); openFileDialog.Title = "Open " + projectTypeName; if (openFileDialog.ShowDialog() == DialogResult.OK) { string targetPath = openFileDialog.FileName; if (LoadProject(targetPath, ref loadedProject)) { project = loadedProject; openFileDialog?.Dispose(); return(targetPath); } else { MessageBox.Show("Invalid project file.", "Error", MessageBoxButtons.OK); } } if (loadedProject is IDisposable) { (loadedProject as IDisposable).Dispose(); } openFileDialog?.Dispose(); return(null); }
void OpenFileButton_Click (object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog (); ofd.Filter = "Text files (*.txt)|*.txt|Source files (*.cs)|*.cs|Application files (*.exe)|*.exe|All files (*.*)|*.*"; ofd.FilterIndex = 2; ofd.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory; ofd.ShowDialog (); MessageBox.Show (string.Format (CultureInfo.InvariantCulture, "FilterIndex: {0}", ofd.FilterIndex)); ofd.Dispose (); }
/// <summary> /// Function to retrieve a single file name. /// </summary> /// <returns>The selected file path, or <b>null</b> if cancelled.</returns> public virtual string GetFilename() { OpenFileDialog dialog = null; try { dialog = GetDialog(false); return(dialog.ShowDialog(GetParentForm()) == DialogResult.Cancel ? null : dialog.FileName); } finally { dialog?.Dispose(); } }
protected void clickOpen(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "ficheros de texto |*.txt|Todos los ficheros|*.*"; if(ofd.ShowDialog() == DialogResult.OK) { String filename = ofd.FileName; String texto = File.ReadAllText(filename); this._txtTexto.Buffer.Text = texto; } ofd.Dispose(); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = "Text File|*.txt"; if (openFile.ShowDialog() == DialogResult.OK) { StreamReader strRead = new StreamReader(openFile.FileName); richTextBox1.Show(); richTextCheck = true; richTextBox1.Text = strRead.ReadToEnd(); strRead.Dispose(); this.Text = openFile.FileName; NewFile = true; openFile.Dispose(); } Check = true; CheckNew = false; }
/// <summary> /// 添加文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = true; ofd.InitialDirectory = InitDir; ofd.ShowDialog(); string[] FileNames = ofd.FileNames; ofd.Dispose(); //添加文件列表到压缩包,并显示在列表 for (int i = 0; i < FileNames.Length; i++) { //Console.WriteLine(FileNames[i]); Entry entry = new Entry(FileNames[i], @""); _ZipEntity.Add(entry); } IsSave = false; this.FileBrower(); }
private void OpenDocx_Click(object sender, EventArgs e) { var openFileDialog = new OpenFileDialog { InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) }; if (openFileDialog.ShowDialog() == DialogResult.OK) { PathToDoc = openFileDialog.FileName; StatusTextBox.Text = $"Открыт файл: {PathToDoc}"; } else { PathToDoc = ""; StatusTextBox.Text = $"Программа готова к работе"; } openFileDialog.Dispose(); }
private void binariesToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "Tile Map Binaries|*.tmb"; if (dialog.ShowDialog() == DialogResult.OK) { byte[] bytes = File.ReadAllBytes(dialog.FileName); try { Tilemap map = IOUtils.LoadTilemapFromBinaries(bytes); this.tilemapDesigner1.Tilemap = map; this.tilemapDesigner1.Tilemap.UpdateTilemapSize(Program.MasterTileset, this.tilemapDesigner1.RenderSize); this.Redraw(); } catch (Exception ex) { Console.WriteLine(ex); } } dialog.Dispose(); }
private void button2_Click(object sender, EventArgs e) { OpenFileDialog dlgOpenFileDialog = new OpenFileDialog(); dlgOpenFileDialog.Filter = "Image Files(*.jpeg;*.bmp;*.png;*.jpg)|*.jpeg;*.bmp;*.png;*.jpg"; if (dlgOpenFileDialog.ShowDialog() == DialogResult.OK) { try { Image image = Bitmap.FromFile(dlgOpenFileDialog.FileName); pictureBox1.Image = image; } catch { } } dlgOpenFileDialog.Dispose(); }
private void chooseFileButton_Click(object sender, EventArgs e) { var dialog = new OpenFileDialog(); dialog.Multiselect = false; if (dialog.ShowDialog() == DialogResult.OK) { selectedFileName = dialog.FileName; filePathLabel.Text = selectedFileName; colorComboBox.SelectedIndex = 0; } else { selectedFileName = null; } dialog.Dispose(); ShowSourceImage(); }
private void btnBrowse_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); var selectedPlugin = (this.cbDataSource.SelectedItem as DataSourceInfo); var file = this.txtDataSourceLocation.Text; var ext = (file.Split('.')?.Last() ?? "").ToLower(); dialog.Filter = selectedPlugin.Instance.BrowseDialogFileFilter; dialog.InitialDirectory = ext.Length > 0 && File.Exists(file) ? Path.GetDirectoryName(file) : Path.GetPathRoot(Environment.SystemDirectory); dialog.Title = "Select a file for the plugin to handle"; if (dialog.ShowDialog() == DialogResult.OK) { this.txtDataSourceLocation.Text = dialog.FileName; } dialog.Dispose(); dialog = null; }
// // Event methods // // #region private void onSelectClick(object, EventArgs) private void onSelectClick(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.InitialDirectory = @"C:\Windows\System32"; dialog.Filter = "Execute Files(*.exe; *.dll)|*.exe;*.dll|All Files(*.*)|*.*"; dialog.FilterIndex = 0; dialog.Multiselect = false; if (dialog.ShowDialog() == DialogResult.OK) { this.tbxFileName.Text = dialog.FileName; this.UpdateList(); } dialog.Dispose(); dialog = null; }
private void OnClickImport(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog { Multiselect = false, Title = "Choose csv file to import", CheckFileExists = true, Filter = "csv files (*.csv)|*.csv" }; if (dialog.ShowDialog() == DialogResult.OK) { Options.ChangedUltimaClass["Speech"] = true; SpeechList.ImportFromCSV(dialog.FileName); _source.DataSource = SpeechList.Entries; dataGridView1.Invalidate(); } dialog.Dispose(); }
private void button2_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (DialogResult.OK == ofd.ShowDialog(this)) { PrintDialog pd = new PrintDialog(); pd.PrinterSettings = new PrinterSettings(); if (DialogResult.OK == pd.ShowDialog(this)) { RawPrinterHelper.SendFileToPrinter(pd.PrinterSettings.PrinterName, ofd.FileName); } pd.Dispose(); } ofd.Dispose(); }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog o = new OpenFileDialog(); o.Filter = "JPEG Images|*.jpg"; o.AddExtension = true; o.RestoreDirectory = true; o.Title = textBox1.Text + "Insert Image"; o.InitialDirectory = @"D:/"; string choosen_file = ""; if (o.ShowDialog() != DialogResult.Cancel) { choosen_file = o.FileName; pictureBox1.Image = Image.FromFile(choosen_file); } o.Dispose(); o = null; }
private void btn_ImportNPCScript_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Text File (*.txt)|*.txt"; ofd.Multiselect = false; ofd.ShowDialog(); try { NPCScriptBox.Text = File.ReadAllText(ofd.FileName); } catch (Exception ex) { MessageBox.Show(ex.Message); } ofd.Dispose(); }
//Locates file, and place location in source text box. private void buttonBrowse_Click(object sender, EventArgs e) { //Create file dialog, starting in MyDocuments OpenFileDialog dlgOpen = new OpenFileDialog(); dlgOpen.Title = "Open Source File"; dlgOpen.Filter = "Text Files(*.txt)|*.txt|All Files(*,*)|*.*"; dlgOpen.InitialDirectory = Environment.SpecialFolder.MyDocuments.ToString(); //Open dialog and check for OK if (dlgOpen.ShowDialog() == DialogResult.OK) { //Put file location in source box textBoxSourceFilePath.Text = dlgOpen.FileName; } //Dispose of OpenFileDialog dlgOpen.Dispose(); }
/// <summary> /// 添加表格到列表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnAddTable_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog { Multiselect = true, Filter = "(Excel文件)|*.xls;*.xlsx" }; if ((dialog.ShowDialog() == DialogResult.OK) && (dialog.FileNames.Length != 0)) { foreach (string str in dialog.FileNames) { this.lbxSelectBox.Items.Add(str); } dialog.Dispose(); this.btnDeleteTable.Enabled = true; this.btnClearTable.Enabled = true; } }
private void Btn_excel_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "Excel Files | *.xls;*.xlsx;*.xlsm;"; dialog.Title = "Importar"; if (dialog.ShowDialog() == DialogResult.OK) { Lbl_ruta.Visible = true; Lbl_ruta.Text = dialog.FileName; Dgv_tipoOper.DataSource = rtipoOper.ImportarAchivoExcel(dialog.FileName); Tabla(); // Dgv_Importar.Columns[0].HeaderText = "CODIGO"; //ImportarAchivoExcel(dialog.FileName); } dialog.Dispose(); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (!loadPage()) { return; } OpenFileDialog dialog = new OpenFileDialog(); dialog.AddExtension = false; //dialog.DefaultExt = "ctf"; dialog.Filter = "CTF file|*.ctf|CSV file|*.csv|All files|*.*"; dialog.Multiselect = true; dialog.FilterIndex = (int)currentPage.FilterIndex; if (dialog.ShowDialog() == DialogResult.OK) { dialog.Dispose(); loadFile(dialog.FileNames); } }
private void btnOpen_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog { Filter = "结果文件 (*.slp)|*.slp", FilterIndex = 0, RestoreDirectory = true }; if (openFileDialog.ShowDialog() == DialogResult.OK) { XmlSerializer xmlSerializer = new XmlSerializer(timeslip.GetType()); using (FileStream reader = new FileStream(openFileDialog.FileName, FileMode.Open)) { timeslip = (Timeslip)xmlSerializer.Deserialize(reader); reader.Close(); } UpdateTimeslip(); } openFileDialog.Dispose(); }
private void btnSalvar_Click(object sender, EventArgs e) { feedback.NomeAudio = AudioService.CopiaAudioParaPasta(textNomeAudio.Text); feedback.Pontos = Convert.ToInt32(numericPontos.Value); feedback.CorBlink = panelCorBlink.BackColor.ToArgb(); FeedBack feedBackExistente = FeedBackService.GetByObj(feedback); if (feedBackExistente != null) { MessageBox.Show("Feedback já existente!", "Advertência"); return; } FeedBackService.Salvar(feedback); MessageBox.Show("Feedback salvo com sucesso!", "Sucesso"); fileDialog.Dispose(); Close(); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); // openFileDialog.ShowDialog(); //Shows the dialog if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK && openFileDialog.FileName.Contains(".txt")) //Checks if it's all ok and if the file name contains .txt { string open = File.ReadAllText(openFileDialog.FileName); //Reads the text from file richTextBox1.Text = open; //Shows the reded text in the textbox FileInfo f = new FileInfo(openFileDialog.FileName); string path = f.FullName; openFileDialog.Dispose(); watch(path); } else //If something goes wrong... { MessageBox.Show("The file you've chosen is not a text file"); } }
private void FileOpen_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); graph.Clear(); if (open.ShowDialog() == DialogResult.OK) { if (graph.Load(open.FileName)) { MessageBox.Show("Файл успешно загружен!"); filename = open.FileName; } else { MessageBox.Show("Загрузить файл не удалось!"); } } open.Dispose(); }
private void AddSF_Click(object sender, EventArgs e) { String F = "SoundFont files | "; foreach (String Fi in Properties.Settings.Default.SupportedFormats) { F += String.Format("*{0}; ", Fi); } OpenFileDialog OFD = new OpenFileDialog() { Multiselect = true, InitialDirectory = Properties.Settings.Default.LastSoundFontPath, Filter = F }; try { if (OFD.ShowDialog(this) == DialogResult.OK) { Properties.Settings.Default.LastSoundFontPath = Path.GetDirectoryName(OFD.FileNames[0]); Properties.Settings.Default.Save(); ListViewItem[] iSFs = SoundFontListExtension.AddSFToList(OFD.FileNames, BankPresetOverride.Checked, false); if (iSFs != null) { foreach (ListViewItem iSF in iSFs) { Lis.Items.Add(iSF); } } SoundFontListExtension.SaveList(ref Lis, SelectedListBox.SelectedIndex, null); } } catch (Exception ex) { ReloadListAfterError(ex); } OFD.Dispose(); }
} //end constructor //METHODS public bool LoadFile(OpenFileDialog openFileDialog, System.Windows.Controls.Image ImgPicture, DecodeClass decode) { //SETUP OFD INFORMATION WHEN CALLED openFileDialog.Filter = "PPM file (*.ppm)|*.ppm"; openFileDialog.Multiselect = false; openFileDialog.Title = "Image Selector"; //IF YOU LOAD A CORRECT IMAGE AND HIT OK/OPEN if (openFileDialog.ShowDialog() == DialogResult.OK) { //CHECK IF IMAGE WAS LOADED BEFORE if (PreImagePath == openFileDialog.FileName) { return(true); }//end if //SAVE OPENED FILENAME TO CHECK ON SECOND LOAD PreImagePath = openFileDialog.FileName; //GRAB FILENAME AND SEND TO ConvertPPM CLASS ConvertPPM ppm = new ConvertPPM(openFileDialog.FileName); //CONVERT PPM TO BITMAP LoadedBitmap = ppm.ConvertToBitmap(); //SAVE PICTURE TO IMAGE BOX BitmapConverter bmpcon = new BitmapConverter(LoadedBitmap); ImgPicture.Source = bmpcon.ConvertBitmapToImageSource(); //IF YOU TRIED TO LOAD P1 if (ppm.IncorrectLoad) { return(false); }//end if //DISPOSE OF PICTURE openFileDialog.Dispose(); return(true); }//end if return(false); } //end method
private void add_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.CheckFileExists = true; dialog.Multiselect = true; dialog.Filter = ".Net Assembly (*.dll)|*.dll"; if (dialog.ShowDialog() == DialogResult.OK) { foreach (string file in dialog.FileNames) { if (_references.AddReference(file)) { referencesList.Items.Add(Path.GetFileName(file)); } } } dialog.Dispose(); }
/// <summary> /// Function to retrieve a single file name. /// </summary> /// <returns>The selected file path, or <b>null</b> if cancelled.</returns> public string GetFilename() { OpenFileDialog dialog = null; try { dialog = GetDialog(false); string result = dialog.ShowDialog(GetParentForm()) == DialogResult.Cancel ? null : dialog.FileName; _lastSelectedFilterIndex = dialog.FilterIndex; return(result); } finally { dialog?.Dispose(); } }
private void button1_Click(object sender, EventArgs e) { using (var ofd = new OpenFileDialog() { Multiselect = true }) { var result = ofd.ShowDialog(); switch (result) { case DialogResult.Cancel: break; case DialogResult.OK: foreach (var file in ofd.FileNames) { if (new FileInfo(file).Length > 0) { files.Add(new OIVGenericFile(file, file.Substring(file.LastIndexOf("\\") + 1))); } else { MessageBox.Show(string.Format("The file {0} is invalid and cannot be used.", file)); } } break; } ofd.Dispose(); } listBox1.Items.Clear(); listBox2.Items.Clear(); foreach (var file in files) { var filename = file.Source.Substring(file.Source.LastIndexOf("\\") + 1); listBox1.Items.Add(filename); listBox2.Items.Add(filename); } }
private string OpenDialog() { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Title = "移行元ファイルを選択"; openFileDialog1.InitialDirectory = @"C:\Users\kawabe\Desktop\work\db\"; openFileDialog1.FileName = "みのうら2"; openFileDialog1.Filter = "MSACCESS ファイル|*.mdb|すべてのファイル|*.*"; openFileDialog1.FilterIndex = 1; openFileDialog1.RestoreDirectory = true; openFileDialog1.Multiselect = false; openFileDialog1.ShowHelp = false; openFileDialog1.ShowReadOnly = true; openFileDialog1.ReadOnlyChecked = false; openFileDialog1.CheckFileExists = true; openFileDialog1.CheckPathExists = true; openFileDialog1.AddExtension = true; // 有効な Win32 ファイル名だけを受け入れるようにする (初期値 true) //openFileDialog1.ValidateNames = true; try { // ダイアログを表示し、戻り値が [OK] の場合は、選択したファイルを表示する if (openFileDialog1.ShowDialog() == DialogResult.OK) { return openFileDialog1.FileName; } } catch (Exception) { } finally { // 不要になった時点で破棄する (正しくは オブジェクトの破棄を保証する を参照) openFileDialog1.Dispose(); } return string.Empty; }
private void btnEditGame_Click(object sender, System.EventArgs e) { RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Imagine Interactive\Gameserver Panel\Games"); String[] gameList = key.GetSubKeyNames(); String gameName = gameList[this.games.SelectedIndex]; OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = "Ausführbare Dateien|*.exe"; openFile.Title = gameName; if (openFile.ShowDialog() == DialogResult.OK) { FileInfo fi = new FileInfo(openFile.FileName); RegistryKey game = key.OpenSubKey(gameName, true); game.SetValue("isInstalled", 1); if (game.GetValue("needpath").ToString() == "1") { game.SetValue("command", fi.Name); } game.SetValue("installPath", fi.FullName); game.Close(); } openFile.Dispose(); key.Close(); this.loadGames(); }
private void btnDbpro_Click(object sender, EventArgs e) { //dbpro.exe location OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Locate DbPro exe"; ofd.Filter = "Dbpro exe (*.exe)|*.exe|All Files (*.*)|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { dbpExe = ofd.FileName; } ofd.Dispose(); }
public string OpenDialog() { // OpenFileDialog の新しいインスタンスを生成する (デザイナから追加している場合は必要ない) OpenFileDialog openFileDialog1 = new OpenFileDialog(); // ダイアログのタイトルを設定する openFileDialog1.Title = "移行元ファイルを選択"; // 初期表示するディレクトリを設定する openFileDialog1.InitialDirectory = @"C:\Users\kawabe\Desktop\work\db\"; // 初期表示するファイル名を設定する openFileDialog1.FileName = "みのうら2"; // ファイルのフィルタを設定する openFileDialog1.Filter = "MSACCESS ファイル|*.mdb|すべてのファイル|*.*"; // ファイルの種類 の初期設定を 2 番目に設定する (初期値 1) openFileDialog1.FilterIndex = 1; // ダイアログボックスを閉じる前に現在のディレクトリを復元する (初期値 false) openFileDialog1.RestoreDirectory = true; // 複数のファイルを選択可能にする (初期値 false) openFileDialog1.Multiselect = false; // [ヘルプ] ボタンを表示する (初期値 false) openFileDialog1.ShowHelp = false; // [読み取り専用] チェックボックスを表示する (初期値 false) openFileDialog1.ShowReadOnly = true; // [読み取り専用] チェックボックスをオンにする (初期値 false) openFileDialog1.ReadOnlyChecked = false; // 存在しないファイルを指定した場合は警告を表示する (初期値 true) openFileDialog1.CheckFileExists = true; // 存在しないパスを指定した場合は警告を表示する (初期値 true) openFileDialog1.CheckPathExists = true; // 拡張子を指定しない場合は自動的に拡張子を付加する (初期値 true) openFileDialog1.AddExtension = true; // 有効な Win32 ファイル名だけを受け入れるようにする (初期値 true) //openFileDialog1.ValidateNames = true; try { // ダイアログを表示し、戻り値が [OK] の場合は、選択したファイルを表示する if (openFileDialog1.ShowDialog() == DialogResult.OK) { return openFileDialog1.FileName; // Multiselect が true の場合はこのように列挙する //foreach (string nFileName in openFileDialog1.FileNames) { // MessageBox.Show(nFileName); //} } } catch (Exception) { } finally { // 不要になった時点で破棄する (正しくは オブジェクトの破棄を保証する を参照) openFileDialog1.Dispose(); } return string.Empty; }
private void btnBrowseTemplate_Click(object sender, RoutedEventArgs e) { OpenFileDialog file_dialog = new OpenFileDialog(); if (file_dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { txtTemplateDirectory.Text = file_dialog.FileName; } file_dialog.Dispose(); }
/// <summary> /// Restore current user's settings and problem description from a .uapak file. /// Depends on external program "unzip\zipit.exe" /// </summary> public static void RestoreData() { string path = LocalDirectory.DefaultPath; if (!System.IO.Directory.Exists(path)) return; string file = @"unzip\zipit.exe"; file = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), file); if (!System.IO.File.Exists(file)) return; OpenFileDialog ofd = new OpenFileDialog(); ofd.FileName = "Problems.uapak"; ofd.Filter = "UVA Arena Package | *.uapak"; if (ofd.ShowDialog() == DialogResult.OK) { System.Threading.ThreadPool.QueueUserWorkItem(Restore, ofd.FileName); } ofd.Dispose(); }
private void selectNewExe_Click(object sender, EventArgs e) { //select new exe OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Select new exe"; ofd.Filter = "Dbpro exe (*.exe)|*.exe|All Files (*.*)|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; newExeName = ofd.FileName; gbNew.Text = "New exe (" + Path.GetFileName(ofd.FileName) + ")"; newExe.BeginUpdate(); newExe.Items.Clear(); proExe.LoadExe(newExe, true, ofd.FileName); foreach (ListViewItem lvi in newExe.Items) { lvi.UseItemStyleForSubItems = false; } newExe.EndUpdate(); //analyse if required if (oldExeName != null) analyse(); Cursor.Current = Cursors.Default; } ofd.Dispose(); }
private void browse_Click(object sender, System.EventArgs e) { //browse for file OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Select file"; dlg.Filter = "All files (*.*)|*.*"; if (dlg.ShowDialog() == DialogResult.OK) { pathname.Text = dlg.FileName; } dlg.Dispose(); }
private void load_Click(object sender, EventArgs e) { //load OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Selet Dbpro exe"; dlg.Filter = "Exe files (*.exe)|*.exe|All Files(*.*)|*.*"; if (dlg.ShowDialog() == DialogResult.OK) { Intern.Enabled = true; Intern.Items.Clear(); Extern.Enabled = true; Extern.Items.Clear(); if (exeType.SelectedIndex == 0) { //new type Targetexe.Enabled = false; } else { //old type Targetexe.Enabled = true; } //load exe proExe.LoadExe(Extern, dlg.FileName); //move required items into Intern foreach (ListViewFileItem lvi in Extern.Items) { if (lvi.Text.StartsWith("<") || lvi.Text == "_virtual.dat") { lvi.Remove(); Intern.Items.Add(lvi); } } Loaded_ExeName = dlg.FileName; if (Targetexe.Text == "") Targetexe.Text = "mini_"+Path.GetFileName(dlg.FileName); Intern.EndUpdate(); Extern.EndUpdate(); } dlg.Dispose(); }
private void load_Click(object sender, EventArgs e) { //load OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Load"; dlg.Filter = "Builder settings files (*.bsf)|*.bsf|All Files (*.*)|*.*"; if (dlg.ShowDialog() == DialogResult.OK) { FileStream fs = null; BinaryReader br = null; //clear items name.Text = ""; filename.Text = ""; checksum.Text = ""; info.Text = ""; files.Items.Clear(); try { fs = new FileStream(dlg.FileName,FileMode.Open); br = new BinaryReader(fs); name.Text = br.ReadString(); filename.Text = br.ReadString(); checksum.Text = br.ReadString(); info.Text = br.ReadString(); //files ListViewFileItem itm; while (fs.Position != fs.Length) { itm = new ListViewFileItem(); itm.Text = br.ReadString(); itm.SubItems.Add(br.ReadString()); itm.SubItems.Add(br.ReadString()); itm.Offset = br.ReadInt32(); itm.Size = br.ReadInt32(); files.Items.Add(itm); } } catch (Exception ex) { MessageBox.Show(ex.ToString(),"Error",MessageBoxButtons.OK,MessageBoxIcon.Error); } finally { br.Close(); fs.Close(); } //enable build and save buttons build.Enabled = true; save.Enabled = true; } dlg.Dispose(); }
private void mLoadOnClick(object sender, EventArgs e) { //load exe OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Select exe"; ofd.Filter = "Exe or Pck files (*.exe, *.pck)|*.exe;*.pck|All Files (*.*)|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { LoadExe(ofd.FileName); } ofd.Dispose(); }
private void mInsertOnClick(object obj, EventArgs ea) { //insert new file above selected item if (list.SelectedItems.Count > 1) { MessageBox.Show("Can not insert with more than one item selected.","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Select file"; dlg.Filter = "All Files (*.*)|*.*|Dll Files (*.dll)|*.dll"; if (dlg.ShowDialog() == DialogResult.OK) { try { string length; long len; FileStream fs = new FileStream(dlg.FileName,FileMode.Open); BinaryReader br = new BinaryReader(fs); len = fs.Length; // check for _virtual.dat and read display info if (Path.GetFileName(dlg.FileName) == "_virtual.dat") { displayBox.Enabled = true; displayType.SelectedIndex = br.ReadInt32(); displayWidth.Text = br.ReadInt32().ToString(); displayHeight.Text = br.ReadInt32().ToString(); displayDepth.Text = br.ReadInt32().ToString(); } br.Close(); fs.Close(); if (len > 1024) { len /= 1024; length = len.ToString() + " kB"; } else { length = len.ToString() + " By"; } ListViewItem itm = new ListViewItem(Path.GetFileName(dlg.FileName)); itm.SubItems.Add(length); itm.SubItems.Add(dlg.FileName); if (list.SelectedItems.Count == 0) { //if there are no selected items add it to the bottom list.Items.Add(itm); } else { //there is one selcted item so insert above it list.Items.Insert(list.SelectedItems[0].Index,itm); } } catch (Exception ex) { MessageBox.Show(ex.ToString(),"Error",MessageBoxButtons.OK,MessageBoxIcon.Error); } } dlg.Dispose(); }
private void btnLoad_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Load Darkbasic Pro exe"; dlg.Filter = "Dbpro exe and pack files (*.exe,*.pck)|*.exe;*.pck|All Files (*.*)|*.*"; if (exePath != "") { dlg.InitialDirectory = exePath; exePath = ""; } if (dlg.ShowDialog() == DialogResult.OK) { load(dlg.FileName); } dlg.Dispose(); }
private void btnDll_Click(object sender, EventArgs e) { //set dll_tool.exe location OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Locate dll_tool.exe"; ofd.Filter = "dll_tool.exe|dll_tool.exe|All Files (*.*)|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { dllTool = ofd.FileName; } ofd.Dispose(); }
private void btnDecrypt_Click(object sender, EventArgs e) { //decrypt file FileStream fsIn; BinaryReader brIn; FileStream fsOut; BinaryWriter bwOut; OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Select file to decrypt"; dlg.Filter = "All Files (*.*)|*.*"; if (dlg.ShowDialog() == DialogResult.OK) { SaveFileDialog sDlg = new SaveFileDialog(); sDlg.Title = "Save decrypted file as"; sDlg.Filter = "Loaded file type (*"+Path.GetExtension(dlg.FileName)+")|*"+Path.GetExtension(dlg.FileName); sDlg.Filter += "|All Files (*.*)|*.*"; if (sDlg.ShowDialog() == DialogResult.OK) { if (dlg.FileName == sDlg.FileName) { MessageBox.Show("Can't decrypt to input file!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); dlg.Dispose(); sDlg.Dispose(); return; } else { byte input,xor; xor = 0x21; //xor = 0xDF; fsIn = new FileStream(dlg.FileName,FileMode.Open); brIn = new BinaryReader(fsIn); fsOut = new FileStream(sDlg.FileName,FileMode.Create); bwOut = new BinaryWriter(fsOut); int i = (int)(fsIn.Position - fsIn.Length); while ((int)(fsIn.Length - fsIn.Position) > 28) { input = brIn.ReadByte(); input = (byte)(xor ^ input); bwOut.Write(input); bwOut.Write(brIn.ReadBytes(28)); } if ((int)(fsIn.Length - fsIn.Position) > 0) { input = brIn.ReadByte(); input = (byte)(xor ^ input); bwOut.Write(input); } if (fsIn.Position < fsIn.Length) bwOut.Write(brIn.ReadBytes((int)(fsIn.Length-fsIn.Position))); brIn.Close(); fsIn.Close(); bwOut.Close(); fsOut.Close(); } } sDlg.Dispose(); } dlg.Dispose(); }
private void MenuItem21Click(object sender, EventArgs e) { var ofd = new OpenFileDialog { InitialDirectory = Program.AppPath, Filter = "iSpy Files (*.ispy)|*.ispy|XML Files (*.xml)|*.xml" }; if (ofd.ShowDialog(this) == DialogResult.OK) { string fileName = ofd.FileName; if (fileName.Trim() != "") { LoadObjectList(fileName.Trim()); } } ofd.Dispose(); }
private void getname_Click(object sender, EventArgs e) { //get filename and md5 checksum OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Select target exe"; dlg.Filter = "Exe Files (*.exe)|*.exe|All Files (*.*)|*.*"; if (dlg.ShowDialog() == DialogResult.OK) { filename.Text = Path.GetFileName(dlg.FileName); //get md5 checksum FileStream fs = null; BinaryReader br = null; try { fs = new FileStream(dlg.FileName,FileMode.Open); br = new BinaryReader(fs); System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] result = md5.ComputeHash(br.ReadBytes((int)fs.Length)); checksum.Text = BitConverter.ToString(result).Replace("-","").ToLower(); } catch (Exception ex) { MessageBox.Show(ex.ToString(),"Error!",MessageBoxButtons.OK,MessageBoxIcon.Warning); } finally { br.Close(); fs.Close(); } } dlg.Dispose(); }
private void mInsertOnClick(object sender, EventArgs ea) { //insert file OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Select file"; ofd.Filter = "All Files (*.*)|*.*|Dll Files (*.dll)|*.dll"; if (ofd.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; InsertFile(ofd.FileName, Path.GetFileName(ofd.FileName), false, false); Cursor.Current = Cursors.Default; } ofd.Dispose(); //enable menu items if (contents.Items.Count > 0) { contents.ContextMenu.MenuItems[MENU_SAVE].Enabled = true; contents.ContextMenu.MenuItems[MENU_TOOLS].MenuItems[MENU_DECOMPRESS].Enabled = true; contents.ContextMenu.MenuItems[MENU_TOOLS].MenuItems[MENU_COMPRESS].Enabled = true; } }
private void uploadImageL10PerUploadToolStripMenuItem_Click(object sender, EventArgs e) { try { OpenFileDialog open = new OpenFileDialog(); open.Filter = "Image Files(*.jpg; *.jpeg; *.tga; *.bmp; *.png)|*.jpg; *.jpeg; *.tga; *.bmp; *.png"; string ext = string.Empty; if (open.ShowDialog() == DialogResult.OK) { Bitmap bitmap = new Bitmap(open.FileName); ext = Path.GetExtension(open.FileName).ToLower(CultureInfo.CurrentCulture); (new UploadImage(instance, bitmap, open.FileName, ext)).Show(this); } open.Dispose(); } catch (Exception) { throw new ApplicationException("Failed loading image"); } }
private void proExeBrowse_Click(object sender, EventArgs e) { //browse for new proExe OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Select Dbpro exe"; ofd.Filter = "Exe Files (*.exe)|*.exe|All Files (*.*)|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { proExe.Text = ofd.FileName; } ofd.Dispose(); }
private void selectOldExe_Click(object sender, EventArgs e) { //select old exe OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Select old exe"; ofd.Filter = "Dbpro exe (*.exe)|*.exe|All Files (*.*)|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; oldExeName = ofd.FileName; gbOld.Text = "Old exe (" + Path.GetFileName(ofd.FileName) + ")"; oldExe.BeginUpdate(); oldExe.Items.Clear(); proExe.LoadExe(oldExe, false, ofd.FileName); oldExe.EndUpdate(); //analyse if required if (newExeName != null) analyse(); Cursor.Current = Cursors.Default; } ofd.Dispose(); }