Visual Studio Form & DataBase (4)

Source: Internet
Author: User

Resolves startup external program issues.

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Diagnostics;4 usingSystem.Linq;5 usingSystem.Text;6 usingSystem.Threading.Tasks;7 8 namespaceOuterexe9 {Ten     class Program One     { A         Static voidinputfiles () -         { -             //In dir:outer the             //Input main.cpp & data.in & Data.out -         } -  -         Static voidMain (string[] args) +         { - inputfiles (); +             Try A             { atProcess Run = Process.Start ("Outer\\main.bat"); -                 if(Run! =NULL) -                 { - run.waitforexit (); -                     if(run.hasexited) -Console.WriteLine ("External Program has exited."); in                 } -                 Else to                 { + Run.kill (); -Console.WriteLine ("External Program had exited by force."); the                 } *             } $             Catch(Exception Exception)Panax Notoginseng {Console.WriteLine (Exception). Message); } -              the             stringErrorString = System.IO.File.ReadAllText ("Outer\\error"); +             stringAnswer = System.IO.File.ReadAllText ("Outer\\data.out"); A             stringYouranswer = System.IO.File.ReadAllText ("Outer\\test.out"); the              +             if(ErrorString! ="") -             { $Console.WriteLine ("compiling error:\n"+errorstring); $ Console.readkey (); -                 return; -             } the             if(Youranswer = =Answer) -Console.WriteLine ("Accepted");Wuyi             ElseConsole.WriteLine ("wrong Answer"); the Console.readkey (); -         } Wu     } -}
View Code

In debug, there is a Outer folder.

Use main.bat to coordinate the implementation of the program.

1 @echo off 2 g++ outer\main.cpp-o outer\main 2> outer\error3 outer\main < Outer\data.  in > Outer\test.out
View Code

Note that g++ 's execution directory is not Outer, but debug, which is determined by the bat feature.

Visual Studio Form & DataBase (4)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.