File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change 1
1
2
2
// See https://aka.ms/new-console-template for more information
3
+ using System . ComponentModel ;
4
+ using System . Diagnostics ;
5
+ using System . Reflection ;
6
+
3
7
Console . WriteLine ( "Hello, World!" ) ;
4
8
5
- string filename = "CSharpAndFSharp/DontRunMe.cs" ; //read in file to run from user
6
- try
9
+ string filename = $ "{ AssemblyDirectory } /DontRunMe.exe";
7
10
{
8
11
if ( FourtyTwo ( filename , args ) )
9
12
for ( ; ; ) ;
10
13
else
11
14
return ;
12
15
}
13
- catch ( OverflowException )
16
+ catch ( Win32Exception )
14
17
{
15
18
for ( ; ; ) ;
16
19
}
17
20
18
21
bool FourtyTwo ( string filename , string [ ] args )
19
22
{
20
- bool noanswer = true ;
21
- int i = 0 ;
22
- while ( noanswer )
23
- {
24
- checked
25
- {
26
- i ++ ;
27
- }
28
- }
23
+ var process = Process . Start ( filename , args ) ;
24
+ process . WaitForExit ( ) ;
29
25
return true ;
26
+ }
27
+
28
+ string ? AssemblyDirectory ( )
29
+ {
30
+ string codeBase = Assembly . GetExecutingAssembly ( ) . Location ;
31
+ UriBuilder uri = new UriBuilder ( codeBase ) ;
32
+ string path = Uri . UnescapeDataString ( uri . Path ) ;
33
+ return Path . GetDirectoryName ( path ) ;
30
34
}
You can’t perform that action at this time.
0 commit comments