Esempio n. 1
0
        public void FTP()
        {
            const string ex1 = "C:\\";
            const string ex2 = "C:\\Dir";

            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.CreateNoWindow  = false;
            startInfo.UseShellExecute = false;
            startInfo.FileName        = @"C:\FTP-Lite\FTPServer.exe";
            startInfo.WindowStyle     = ProcessWindowStyle.Hidden;
            startInfo.Arguments       = "-f j -o \"" + ex1 + "\" -z 1.0 -s y " + ex2;

            try
            {
                //Process[] pname = Process.GetProcesses();

                Process[] pname = Process.GetProcessesByName("FTPServer");
                if (pname.Length > 0)
                {
                    //MessageBox.Show("FTP Server is currently Running");
                }
                else
                {
                    //MessageBox.Show("Process Not running");
                    // Start the process with the info we specified.
                    // Call WaitForExit and then the using statement will close.
                    using (Process exeProcess = Process.Start(startInfo))
                    {
                        //exeProcess.WaitForExit();
                        //exeProcess.
                    }
                }
            }
            catch (Exception ex)
            {
                var MsgAlerts = new MessageAlerts();
                MsgAlerts.ExceptionMessage(ex.ToString());
            }
        }
Esempio n. 2
0
        public string CheckFileFormat(bool DirectoryLocation)
        {
            try
            {
                frmMain Main = new frmMain();

                OpenFileDialog openFile = new OpenFileDialog();
                string         outfile  = Properties.Settings.Default.FolderPath + "file.pdf";

                //Limits the user to open file
                if (DirectoryLocation)
                {
                    openFile.InitialDirectory = @"C:\FTP_Location";
                }
                else
                {
                    openFile.InitialDirectory = "This PC";
                }

                openFile.Filter = "DOC files (*.doc)|*.docx ";
                openFile.Filter = "Office Files|*.docx;*.doc;*.pdf;*.pptx;*.ppt;*.xls;*.xlsx";


                if (openFile.ShowDialog() == DialogResult.OK)
                {
                    var splash = new frmSplashScreen();
                    splash.Show();
                    string file      = openFile.FileName;
                    string extension = Path.GetExtension(file);
                    if (extension == ".doc" || extension == ".docx")
                    {
                        ExcelFormat = false;
                        outfile     = ConvertDocToPdf(openFile.FileName);
                    }
                    else if (extension == ".pptx" || extension == ".ptx")
                    {
                        outfile     = ConvertPPTtoPDF(openFile.FileName);
                        ExcelFormat = false;
                    }
                    else if (extension == ".xls" || extension == ".xlsx" || extension == ".xlsm")
                    {
                        outfile     = ConvertExcelToPDF(openFile.FileName);
                        ExcelFormat = true;
                    }
                    else if (extension == ".pdf")
                    {
                        FileInDocFormat = ConvertPDFtoWord(openFile.FileName);
                        outfile         = file;
                        ExcelFormat     = false;
                    }
                    //return null;
                    splash.Close();
                }
                else
                {
                    outfile = "";
                }

                FileToBePrinted = outfile;
                return(outfile);
            }
            catch (Exception ex)
            {
                //if (splash.Visible)
                //    splash.Close();

                var MsgStat = new MessageAlerts();
                MsgStat.ExceptionMessage(ex.Message);
                return(null);
            }
        }