Example #1
0
        public static string More(string s, int maxChar, string readMoreUrl)
        {
            int len = s.Length;

            if (len <= maxChar)
            {
                return(s);
            }

            return(s.Substring(0, maxChar) + " <a href=" + UStr.DQuote(readMoreUrl) + ">Read More...</a>");
        }
Example #2
0
        public static void CopyFolder(string source, string destination)
        {
            string param          = @"/E /H /R /Y";
            string XCopyArguments = UStr.DQuote(source) + " " + UStr.DQuote(destination) + " " + param;

            Process          XCopyProcess   = new Process();
            ProcessStartInfo XCopyStartInfo = new ProcessStartInfo();

            XCopyStartInfo.FileName = "CMD.exe ";

            //do not write error output to standard stream
            XCopyStartInfo.RedirectStandardError = false;
            //do not write output to Process.StandardOutput Stream
            XCopyStartInfo.RedirectStandardOutput = false;
            //do not read input from Process.StandardInput (i/e; the keyboard)
            XCopyStartInfo.RedirectStandardInput = false;

            XCopyStartInfo.UseShellExecute = false;
            //Dont show a command window
            XCopyStartInfo.CreateNoWindow = true;

            XCopyStartInfo.Arguments = "/D /c XCOPY " + XCopyArguments;

            XCopyProcess.EnableRaisingEvents = true;
            XCopyProcess.StartInfo           = XCopyStartInfo;

            //start cmd.exe & the XCOPY process
            XCopyProcess.Start();

            //set the wait period for exiting the process
            XCopyProcess.WaitForExit(5 * 60000); //or the wait time you want

            int ExitCode = XCopyProcess.ExitCode;

            //Now we need to see if the process was successful
            if (ExitCode > 0 & !XCopyProcess.HasExited)
            {
                XCopyProcess.Kill();
            }

            //now clean up after ourselves
            XCopyProcess.Dispose();
        }