예제 #1
0
        private void btnOpenFile_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog openFileDlg = new OpenFileDialog();

                openFileDlg.InitialDirectory = Application.StartupPath;
                openFileDlg.Filter           = "TXT|*.txt";

                if (openFileDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    PDFFILE pdfFIle = new PDFFILE(openFileDlg.FileName);

                    SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                    saveFileDialog1.Filter = "PDF|*.pdf";

                    saveFileDialog1.Title = "Save File";
                    if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK && saveFileDialog1.FileName.Length > 0)
                    {
                        pdfFIle.ConvertToFile(saveFileDialog1.FileName);
                    }

                    pdfFIle = null;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
            }
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            PDFFILE = await _context.PDFFILE.FirstOrDefaultAsync(m => m.ID == id);

            if (PDFFILE == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            PDFFILE = await _context.PDFFILE.FindAsync(id);

            if (PDFFILE != null)
            {
                _context.PDFFILE.Remove(PDFFILE);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
            /// <summary>
            /// Return the equivalent enum value based on a string
            /// </summary>
            /// <param name="value">String to be evaluated</param>
            /// <returns>Category enum value</returns>
            /// <remarks></remarks>
            public static Category fromString(String value)
            {
                String s = value.ToLower();

                if (s == DATAFILE.ToString().ToLower())
                {
                    return(DATAFILE);
                }
                else if (s == GRAPHICSPLOT.ToString().ToLower())
                {
                    return(GRAPHICSPLOT);
                }
                else if (s == PDFFILE.ToString().ToLower())
                {
                    return(PDFFILE);
                }
                else if (s == RBINARY.ToString().ToLower())
                {
                    return(RBINARY);
                }
                else if (s == RSCRIPT.ToString().ToLower())
                {
                    return(RSCRIPT);
                }
                else if (s == SHELLSCRIPT.ToString().ToLower())
                {
                    return(SHELLSCRIPT);
                }
                else if (s == TEXTFILE.ToString().ToLower())
                {
                    return(TEXTFILE);
                }
                else
                {
                    return(OTHER);
                }
            }