Exemplo n.º 1
0
        /// <summary>
        /// Create Browse Dialog
        /// </summary>
        /// <param name="Filterargs"></param>
        /// <param name="dirpath"></param>
        /// <param name="filepath"></param>
        /// <param name="textbox"></param>
        public void OFileDialog(string Filterargs, string dirpath, string filepath, string exename, TextBox textbox)
        {
            string textforfile;

            OpenFileDialog ofd = new OpenFileDialog
            {
                InitialDirectory = @"C:\",
                Title            = "Find Exe of Application",
                DefaultExt       = "exe",
                Multiselect      = false
            };

Reshow:

            ofd.Filter = Filterargs;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                textforfile = ofd.FileName;
                if (Path.GetExtension(ofd.FileName) != ".exe")
                {
                    MessageBox.Show("Invalid File", "Multi-Game Launcher", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    ofd.Reset();
                    goto Reshow;
                }
                else
                {
                    textbox.Text = ofd.FileName;
                    Functions.CreateFile(dirpath, filepath, textforfile);
                    ofd.Reset();
                }
            }
        }
Exemplo n.º 2
0
 private void btnSelectOutputData_Click(object sender, EventArgs e)
 {
     openFileDialog1.Reset();
     openFileDialog1.FileName = "选择输出文件";
     Text = openFileDialog1.Title;
     openFileDialog1.Filter = "output*.*;|*.*;";
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         //将路径显示出来
         textBox1.Text = openFileDialog1.FileName;
         filename      = textBox1.Text;
         FileStream hr = new FileStream(filename, FileMode.Open);
         //按行文件读
         StreamReader sh = new StreamReader(hr);
         //每行存放的数据
         string data;
         while ((data = sh.ReadLine()) != null)
         {
             list.Add(data);
             number++;
         }
         hr.Close();
         sh.Close();
         //richTextBox1.Text = list[8];
     }
 }
Exemplo n.º 3
0
        private void Button2_Click(object sender, EventArgs e)
        {
            openFileDialog2.Reset();
            openFileDialog2.CheckFileExists = true;
            openFileDialog2.CheckPathExists = true;
            openFileDialog2.Title           = "Select First Name List File";
            openFileDialog2.Filter          = "txt files (*.txt)|*.txt";
            DialogResult openFileDialog2DialogResult = openFileDialog2.ShowDialog();

            if (openFileDialog2DialogResult == DialogResult.OK)
            {
                listBox2.Items.Clear();
                StreamReader firstNamesListStreamReader = new StreamReader(openFileDialog2.FileName);
                string       line;
                while ((line = firstNamesListStreamReader.ReadLine()) != null)
                {
                    listBox2.Items.Add(line);
                }
                firstNamesListStreamReader.Close();
            }
            else
            {
                MessageBox.Show(this, "You are not selected a File!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 4
0
        protected override int VisualMain()
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Reset();
            fileDialog.Title       = Res("EFlashRecoverySelectingTitle");
            fileDialog.Filter      = Res("EFlashRecoverySelectingFilter");
            fileDialog.Multiselect = false;
            if (fileDialog.ShowDialog() != true)
            {
                return(ERR_CANCELED_BY_USER);
            }
            fileDialog = null;

            var result = CmdStation
                         .GetFastbootCommand(TargetDevice,
                                             $"flash recovery \"{fileDialog.FileName}\"")
                         .To(OutputPrinter)
                         .Execute();

            if (result.ExitCode == 0)
            {
                CmdStation
                .GetFastbootCommand(TargetDevice,
                                    $"boot \"{fileDialog.FileName}\"")
                .To(OutputPrinter)
                .Execute();
            }

            WriteExitCode(result.ExitCode);
            return(result.ExitCode);
        }
Exemplo n.º 5
0
        private void btnLoadCv_Click(object sender, EventArgs e)
        {
            using (var openCvFileDialog = new OpenFileDialog())
            {
                openCvFileDialog.Filter = "Книга Excel (*.xlsx)|*.xlsx| (*.xls)|*.xls";
                if (openCvFileDialog.ShowDialog() == DialogResult.OK)
                {
                    string fileName = openCvFileDialog.FileName;
                    openCvFileDialog.Reset();
                    var cv = CvHandler.LoadCv(fileName);
                    foreach (var pair in cv)
                    {
                        string[] arr = { pair.Key, pair.Value };
                        lvCv.Items.Add(new ListViewItem(arr));
                        lvCv.Update();
                    }

                    var jobs = KnowledgeBase.GetJobs();

                    cv = cv.FilterValues();
                    CvHandler.AnalyzeCv(cv, jobs);
                    lvCv.Clear();
                }
            }
        }
Exemplo n.º 6
0
 public void EntryPoint(ILeafUI ui, IDevice device, ICommandExecutor executor)
 {
     using (ui)
     {
         using (executor)
         {
             var text = ClassTextReaderCache.Acquire <EFlashRecovery>();
             ui.Show();
             OpenFileDialog fileDialog = new OpenFileDialog();
             fileDialog.Reset();
             fileDialog.Title       = text["Title"];
             fileDialog.Filter      = text["Filter"];
             fileDialog.Multiselect = false;
             if (fileDialog.ShowDialog() == true)
             {
                 executor.OutputReceived += (s, e) => ui.WriteLineToDetails(e.Text);
                 executor.Fastboot(device, $"flash recovery \"{fileDialog.FileName}\"");
                 var result = executor.Fastboot(device, $"boot \"{fileDialog.FileName}\"");
                 ui.Finish(result.ExitCode == 0 ? StatusMessages.Success : StatusMessages.Failed);
             }
             else
             {
                 ui.Shutdown();
             }
         }
     }
 }
Exemplo n.º 7
0
        public void DoOpenReadFileCommand()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
                FilterIndex = 2,
                RestoreDirectory = true,
                Title = "ReadFile"
            };

            try
            {
                if (openFileDialog.ShowDialog() == true)
                {
                    PathFileRead = openFileDialog.FileName;

                    if (PathFileWrite == PathFileRead)
                    {
                        throw new Exception("Ошибка: Имя файла совпадает с другим именем файла. ");
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

                openFileDialog.Reset();
                openFileDialog.ShowDialog();
                PathFileRead = "";
            }
        }
Exemplo n.º 8
0
        private void BtnOpenMNistClick(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog();

            dialog.Title  = "Выберите файл изображений";
            dialog.Filter = "Файл изображений|*.idx3-ubyte";
            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var imagesPath = dialog.FileName;

            dialog.Reset();
            dialog.Title  = "Выберите файл подписей";
            dialog.Filter = "Файл подписей|*.idx1-ubyte";
            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var labelsPath = dialog.FileName;

            nistImages = MNistFileManager.GetImageSet(labelsPath, imagesPath);

            udMNistImageIndex.Maximum = nistImages.Length - 1;
            lblMNistInfo.Text         = string.Format("{0} элементов", nistImages.Length);
            lblMNistInfo.ForeColor    = Color.DarkGreen;

            UdMNistImageIndexValueChanged(udMNistImageIndex, EventArgs.Empty);
            DisablePanels(PanelsState.AllEnabled);
        }
Exemplo n.º 9
0
        private void OpenFiles()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Reset();

            dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
            dialog.Title            = Strings.PleaseSelectFile;
            dialog.Multiselect      = true;

            dialog.Filter = this.Filter;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                List <FileInfo> files = new List <FileInfo>();

                for (int i = 0; i < dialog.FileNames.Length; i++)
                {
                    var path      = dialog.FileNames[i];
                    var fileName  = dialog.SafeFileNames[i];
                    var extension = IOUtil.GetExtension(fileName);

                    var file = new FileInfo(fileName, path, extension);
                    files.Add(file);
                }
                AddFiles(files);
            }
        }
Exemplo n.º 10
0
 public void openXmlToolStripMenuItem_Click(object sender, EventArgs e)
 {
     path = OpnDialog();
     if (path == null)
     {
         MessageBox.Show("file doesn't exist ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         opendialog.Reset();
     }
     else
     {
         List <string> nameFilm = new List <string>();
         bool          flag     = true;
         listBox1.Items.Clear();
         flowLayoutPanel1.Controls.Clear();
         if (plugins.Count == 0)
         {
             try
             {
                 emptyPlugin(flag);
             }
             catch (SecurityException ex)
             {
                 MessageBox.Show("Security error.\n\nError message: {ex.Message}\n\n" +
                                 "Details:\n\n{ex.StackTrace}" + ex);
             }
         }
         else
         {
             flag = false;
             emptyPlugin(flag);
             outplugins(path);
         }
     }
 }
Exemplo n.º 11
0
        private string OpnDialog()
        {
            opendialog             = new OpenFileDialog();
            opendialog.Filter      = "XML Files (*.xml)|*.xml";
            opendialog.FilterIndex = 1;
            opendialog.Multiselect = false;
            if (opendialog.ShowDialog() == DialogResult.OK)
            {
                path = opendialog.FileName;
            }
            else
            {
                DialogResult dialogResult = MessageBox.Show("Open file *.xml", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                if (dialogResult == DialogResult.OK)
                {
                    OpnDialog();
                }
                if (dialogResult == DialogResult.Cancel)
                {
                    opendialog.Reset();
                }
            }

            return(path);
        }
Exemplo n.º 12
0
        private void btnImgFileName_Click(object sender, EventArgs e)
        {
            picSource.Image  = null;
            picCaptche.Image = null;

            OpenFileDialog open = new OpenFileDialog();

            open.Reset();
            open.ShowDialog();
            txtImageFileName.Text = open.FileName;

            if (txtImageFileName.Text.Trim() != string.Empty)
            {
                try
                {
                    picSource.Image = Image.FromFile(txtImageFileName.Text.Trim());

                    bit = new Bitmap(picSource.Image);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "郁闷!你选的是图片吗?");
                }
            }
        }
Exemplo n.º 13
0
        private void openButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Filter = "Image Files|*.jpg;*.jpeg;*.png;*.gif;*.bmp;*.tif;*.tiff";
            openFile.Title  = "Select an Image File";
            if (openFile.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Bitmap picObj;
                    using (FileStream openStream = new FileStream(openFile.FileName, FileMode.Open, FileAccess.Read))
                    {
                        MemoryStream openMem = new MemoryStream();
                        openStream.CopyTo(openMem);
                        openMem.Seek(0, SeekOrigin.Begin);
                        picObj = (Bitmap)Image.FromStream(openMem);
                    }
                    picBox.Image         = picObj;
                    fileName             = Path.GetFileNameWithoutExtension(openFile.SafeFileName);
                    extIndex             = Ext_to_Index(Path.GetExtension(openFile.SafeFileName).ToLower());
                    resizeButton.Visible = true;
                    saveButton.Visible   = true;
                }
                catch
                {
                    MessageBox.Show("The file specified could not be opened.", "Error");
                }
            }
            openFile.Reset();
        }
Exemplo n.º 14
0
 private void CloseBtn_Click(object sender, RoutedEventArgs e)
 {
     txtBox.IsEnabled  = false;
     txtBox.Visibility = Visibility.Hidden;
     txtBox.Text       = "";
     OpenFileDialog.Reset();
     InitFileDialog();
 }
 private void ChooseSchemeButton_Click(object sender, EventArgs e)
 {
     if (OpenFileDialog.ShowDialog() == DialogResult.OK)
     {
         SchemeTextBox.Text = OpenFileDialog.FileName;
         OpenFileDialog.Reset();
     }
 }
Exemplo n.º 16
0
        void BuildAttachment(object sender, EventArgs e)
        {
            fileDialog.InitialDirectory = initialdirectory;
            fileDialog.Reset();
            fileDialog.Multiselect = false;

            var result = fileDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                string selected = fileDialog.FileName;
                try
                {
                    var file = File.ReadAllBytes(selected);
                    //Limits the size of the attachment to 1.45 MB, which is less than the max possible size of an SMS attachment of 1.5 MB.
                    if (file.Length > 1450000)
                    {
                        MessageBox.Show("The attachment provided " + fileDialog.SafeFileName + " is too big to be sent by SMS. Please select another.", "Attachment not added.");
                        return;
                    }
                    else
                    {
                        attachment = file;
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("There was an issue with retrieving the file.", "File Operation Error");
                }
            }
            else
            {
                return;
            }

            if (attachment != null)
            {
                string smallname = fileDialog.SafeFileName;
                attachmentname = fileDialog.SafeFileName;

                string name      = Path.GetFileNameWithoutExtension(smallname);
                string extension = Path.GetExtension(smallname);
                if (smallname.Length > 12)
                {
                    smallname         = name.Substring(0, 7) + ".." + extension;
                    attachButton.Text = smallname;
                }
                else
                {
                    attachButton.Text = smallname;
                }

                removeButton.Visible = true;
                attachButton.Width   = 115;
                attachmenttype       = ChatForm.ChatUtility.GetMimeType(extension);
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// This method calls the editor dialog used in the property grid.
        /// </summary>
        /// <remarks>
        /// This method can invoke an internal dialog or an external one. The external one is called whenever a
        /// callback is set. To set an external dialog simple set the
        /// <see cref="GuruComponents.Netrix.UserInterface.TypeEditors.UITypeEditorUrl.UIEditorCallback">UIEditorCallback</see> delegate of type
        /// <see cref="GuruComponents.Netrix.UserInterface.TypeEditors.UIUrlEditor">UIUrlEditor</see>.
        /// </remarks>
        /// <param name="context">The component which contains the property beeing edited.</param>
        /// <param name="provider">The service provider which invokes the editor.</param>
        /// <param name="val">The value currently beeing set in the property.</param>
        /// <returns>The changed value the user has created using the invoked dialog.</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object val)
        {
            if (context != null && context.Instance != null && provider != null)
            {
                service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                string value = val.ToString();
                if (service != null)
                {
                    bool StartOver = true;
                    // look for a delegate attached by host app
                    if (UIEditorCallback != null)
                    {
                        StartOver = false;
                        string       oldVal = value;
                        DialogResult result = UIEditorCallback(context, ref value);
                        if (result != DialogResult.OK)
                        {
                            value = oldVal;
                            if (result == DialogResult.Ignore)
                            {
                                StartOver = true;
                            }
                        }
                    }
                    if (StartOver)
                    {
                        // get the string in the property box
                        openFileDialog.Reset();
                        switch (context.Instance.GetType().ToString())
                        {
                        case "GuruComponents.Netrix.WebEditing.Elements.FrameElement":
                        case "GuruComponents.Netrix.WebEditing.Elements.FormElement":
                        case "GuruComponents.Netrix.WebEditing.Elements.IFrameElement":
                        case "GuruComponents.Netrix.WebEditing.Elements.AnchorElement":
                            openFileDialog.Filter = "HTML|*.htm;*.html|Active Scripting|*.php;*.asp;*.aspx;*.php4;;*.cgi;*.pl; *.phtml|All Files (*.*)|*.*";
                            break;

                        default:
                            openFileDialog.Filter = "Web Image files (*.PNG;*.JPG;*.GIF)|*.jpg;*.jpeg;*.gif;*.png|All Files (*.*)|*.*";
                            break;
                        }
                        openFileDialog.Multiselect      = false;
                        openFileDialog.CheckFileExists  = false;
                        openFileDialog.FilterIndex      = 0;
                        openFileDialog.RestoreDirectory = true;
                        openFileDialog.Title            = "File Selection";
                        if (openFileDialog.ShowDialog() == DialogResult.OK)
                        {
                            value = openFileDialog.FileName;
                        }
                    }
                }
                val = value;
            }
            return(val);
        }
Exemplo n.º 18
0
        private void AddProgramFlyoutButton_Click(object sender, RoutedEventArgs e)
        {
            if (openFileDialog.FileName == "")
            {
                e.Handled = false;
                WinUIMessageBox.Show(null, "No program is selected!", "ERROR", MessageBoxButton.OK,
                                     MessageBoxImage.Error);
                return;
            }
            AddFlyout.IsOpen = false;

            /*try
             * {
             *  ProgramsComboBox.Items.Add(selectedProgram[0] + " - " + BrightnessTrackBar.Value);
             *  ProgramsComboBox.RefreshData();
             * }
             * catch (NullReferenceException )
             * {
             *  WinUIMessageBox.Show(null, "No program is selected!", "ERROR", MessageBoxButton.OK,
             *      MessageBoxImage.Error);
             * }*/

            //SetBrightness((byte)defaultBrightness);
            programs.Add(selectedProgram[0]);
            brightnesses.Add((byte)BrightnessTrackBar.Value);


            SelectProgram.Content = "Select Program";

            LayoutPanel  layoutPanel  = new LayoutPanel();
            TrackBarEdit trackBarEdit = new TrackBarEdit();

            layoutPanel.AllowRestore       = true; layoutPanel.Content = trackBarEdit;
            trackBarEdit.Value             = brightnesses[programsCount];
            trackBarEdit.EditValueChanged += new EditValueChangedEventHandler(trackBarEdit_EditValueChanged);
            directoriesList.Add(openFileDialog.FileName);
            Icon        icon        = System.Drawing.Icon.ExtractAssociatedIcon(openFileDialog.FileName);
            ImageSource imageSource = Imaging.CreateBitmapSourceFromHIcon(
                icon.Handle,
                Int32Rect.Empty,
                BitmapSizeOptions.FromEmptyOptions());


            layoutPanel.CaptionImage = imageSource;
            FileVersionInfo myFileVersionInfo =
                FileVersionInfo.GetVersionInfo(openFileDialog.FileName);

            programsTitleList.Add(myFileVersionInfo.FileDescription);

            layoutPanel.Caption = myFileVersionInfo.FileDescription;
            DockLayoutManager.DockController.Dock(layoutPanel, LayoutGroup1, DockType.Top);
            programsCount += 1;
            openFileDialog.Reset();
            SetBrightness((byte)defaultBrightness);
        }
Exemplo n.º 19
0
        private void BrowserYml_Click(object sender, EventArgs e)
        {
            // Show the dialog and get result.
            openFileDialog.Reset();
            DialogResult result = openFileDialog.ShowDialog();

            if (result == DialogResult.OK) // Test result.
            {
                textBoxBrowseByml.Text = openFileDialog.FileName;
            }
        }
Exemplo n.º 20
0
        public async Task <String[]> Abrir()
        {
            Pesquisa.Reset();
            Pesquisa.Multiselect = true;
            Pesquisa.Title       = "Selecione o Arquivo";
            //Pesquisa.Filter = "*.CSV|*.CSV";
            Pesquisa.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            Pesquisa.ShowDialog();

            return(Pesquisa.FileNames);
        }
Exemplo n.º 21
0
 private void btnDel_Click(object sender, EventArgs e)
 {
     if (op.FileName != null)
     {
         op.Reset();
         lbFile.Text = "(Chưa có Tập tin nào được chọn)";
         btnOpenFile.Show();
         btnDel.Hide();
         txtPort.Enabled  = false;
         file             = null;
         btnStart.Enabled = false;
     }
 }
Exemplo n.º 22
0
 //-------------------------Functions-----------------------------
 //-------------------------Form Events-----------------------------
 private void btn_SelectFiles_Click(object sender, EventArgs e)
 {
     ofd.Reset();
     clearall();
     ofd.Multiselect = true;
     ofd.ShowDialog();
     foreach (string file in ofd.FileNames)
     {
         txt_output.Text += Path.GetFileName(file);
         txt_output.Text += Environment.NewLine;
         fileObjects.Add(new fileObject(Path.GetExtension(file), file, FileByteScan(file)));
     }
 }
        private void InitializeJSONbyFile()
        {
            string importedfilestring = "";

            dlg.Reset();
            dlg.DefaultExt = ".JSON";
            dlg.Filter     = "JSON files (*.JSON)|*.JSON";
            dlg.ShowDialog();
            if (dlg.FileName.Length > 3)
            {
                try
                {
                    GlobalJSONData.filepath = dlg.FileName;
                }
                catch
                {
                    MessageBox.Show("Please select JSON file before start.");
                    return;
                }
                finally
                {
                    dlg.Reset();
                }
            }
            else
            {
                MessageBox.Show("Please select file before start.");
                return;
            }

            using (FileStream fs = new FileStream(GlobalJSONData.filepath, FileMode.Open))
            {
                StreamReader sr = new StreamReader(fs, GlobalJSONData.nowencoding);
                importedfilestring = sr.ReadToEnd();
            }
            ParseJSON(importedfilestring);
        }
Exemplo n.º 24
0
        private void UIBrowse_Btn_Click(object sender, EventArgs e)
        {
            PathSel?.Reset();
            PathSel = new OpenFileDialog()
            {
                CheckPathExists = true,
                Filter          = "UI File|*.ui",
                Multiselect     = false
            };

            if (PathSel.ShowDialog() == DialogResult.OK)
            {
                UIPath.Text = PathSel.FileName;
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Show a openfiledialogbox with the specified extension list.
        /// </summary>
        /// <param name="dialog"></param>
        /// <param name="extensionWithoutDot"></param>
        /// <returns>The selected file, or <see cref="String.Empty"/> if no file was selected.</returns>
        public static string GetOpenFileName(OpenFileDialog dialog, string extensionWithoutDot)
        {
            dialog.Reset();
            dialog.CheckFileExists = true;
            dialog.Title           = "Open File";
            dialog.Filter          = string.Format("{0} files (*.{0})|*.{0}|All files (*.*)|*.*", extensionWithoutDot);
            dialog.DefaultExt      = extensionWithoutDot;
            dialog.FilterIndex     = 0;
            dialog.ShowDialog();

            if (dialog.FileName.Length == 0)
            {
                return("");
            }
            return(dialog.FileName);
        }
Exemplo n.º 26
0
        /// <summary>
        /// // Select PDF File for upload
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_send_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            txtBox_FileSelected.Text = string.Empty;

            dlg.Reset();
            dlg.FileName         = string.Empty;
            dlg.Multiselect      = true;
            dlg.Filter           = "pdf files (*.pdf) |*.pdf;";
            dlg.Title            = "Select PDF files to upload";
            dlg.RestoreDirectory = true;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                // Read the files

                foreach (String file in dlg.FileNames)
                {
                    try
                    {
                        string fileName = Path.GetFileName(file);
                        if (file != null)
                        {
                            //Save FileNames & Base64Files to Dictionary
                            ListFiles64.Add(fileName, this.convertPDF2base64(file));

                            if (txtBox_FileSelected.TextLength == 0)
                            {
                                txtBox_FileSelected.Text = fileName;
                            }
                            else
                            {
                                txtBox_FileSelected.Text += System.Environment.NewLine + txtBox_FileSelected.Text;
                            }
                        }
                    }

                    catch (Exception ex)
                    {
                        MessageBox.Show("Cannot Open PDF: " + file.Substring(file.LastIndexOf('\\'))
                                        + ". You may not have permission to read the file, or " +
                                        "it may be corrupt.\n\nReported error: " + ex.Message);
                    }
                }
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Opens file chooser dialog, and put path to Textbox
        /// </summary>
        /// <param name="textBox">textbox to which will be written file path</param>
        internal static string OpenChooseFileDialog(TextBox textBox)
        {
            var dialog = _fileDialog;

            dialog.Filter = "Excel Files|*.xls;*.xlsx;*.xlsm";
            var dialogResult = dialog.ShowDialog();

            switch (dialogResult)
            {
            case DialogResult.OK:
                textBox.Text = _fileDialog.FileName;
                return(_fileDialog.FileName);
            }

            _fileDialog.Reset();
            return(string.Empty);
        }
Exemplo n.º 28
0
 private void btnLocationHDRExcel_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog openFileDialog = new OpenFileDialog())
     {
         openFileDialog.Reset();
         //openFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
         openFileDialog.RestoreDirectory = true;
         openFileDialog.Filter           = "Excel files (*.xls or *.xlsx)|*.xls;*.xlsx";
         openFileDialog.CheckFileExists  = true;
         openFileDialog.CheckPathExists  = true;
         openFileDialog.Multiselect      = false;
         if (openFileDialog.ShowDialog() == DialogResult.OK)
         {
             this.txtHDRExcelPath.Text = openFileDialog.FileName;
         }
     }
 }
Exemplo n.º 29
0
        private void openF3ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog OP = new OpenFileDialog();

            OP.Filter      = "JPEG Image|*.jpg|Bitmap Image|*.bmp|GIF Image|*.gif|PNG Image | *.png";
            OP.Title       = "Open an Image File";
            OP.FilterIndex = 1; //По умолчанию будет выбрано первое расширение *.jpg И, когда пользователь укажет нужный путь к картинке, ее нужно будет загрузить в PictureBox:
            if (OP.ShowDialog() != DialogResult.Cancel)
            {
                pictureBox1.Load(OP.FileName);
                picDrawingSurface.AutoSize = true;
            }
            else
            {
                OP.Reset();
            }
        }
Exemplo n.º 30
0
        public string Open()
        {
            var fileDialog = new OpenFileDialog
            {
                Filter = "Text files (*.txt, *.csv) | *.txt; *.csv;"
            };

            var result = fileDialog.ShowDialog();

            if (result == true)
            {
                string file = fileDialog.FileName;
                fileDialog.Reset();
                return(file);
            }
            return(null);
        }