What's wrong with the following code?
2005-01-14 15:26
253 查看
Suppose a C# console application named "SearchFile.exe" with one class SearchFile
public class SearchFile
{
public static void Main(string[] args)
{
if(System.IO.File.Exists("hello.txt"))
System.Console.Out.Writeline("Hello has been found!");
else
System.Console.Out.Writeline("Hello has NOT been found!");
}
}
and a text file "hello.txt" were stored in "C:\folder1" and another application with class
public class LaunchAnotherApp
{
public static void Main(string[] args)
{
System.Diagnostic.Process.Start("");
}
}
stored in "C:\folder2".
Run the first app. "Hello has been found!" was got.
Run the second one. "Hello has NOT been found!" was got.
In two runs, the same application "SearchFile.exe" was started. But we got two different results. What is the reason?
Let the system architectures in our lab give a reasonable answer.
public class SearchFile
{
public static void Main(string[] args)
{
if(System.IO.File.Exists("hello.txt"))
System.Console.Out.Writeline("Hello has been found!");
else
System.Console.Out.Writeline("Hello has NOT been found!");
}
}
and a text file "hello.txt" were stored in "C:\folder1" and another application with class
public class LaunchAnotherApp
{
public static void Main(string[] args)
{
System.Diagnostic.Process.Start("");
}
}
stored in "C:\folder2".
Run the first app. "Hello has been found!" was got.
Run the second one. "Hello has NOT been found!" was got.
In two runs, the same application "SearchFile.exe" was started. But we got two different results. What is the reason?
Let the system architectures in our lab give a reasonable answer.
相关文章推荐
- The following code fails when ExecMethod is called. Can anyone pinpoint what I am doing wrong?
- What’s the problems with the following code
- What's wrong with this code
- Programming Basic--what is the output of the following code?
- ArcEngine之Provide your license server administrator with the following information.error code =-42
- What will the following polymorphic code output in C ++
- 面试题:What will happen when you attempt to compile and run the following code
- What's wrong with the string class defined by the draft standard?
- DNN出错:The compiler failed with error code 1.
- Listener refused the connection with the following error 错误解
- Integrate Your Code with the Frameworks---整合你的代码和框架
- What's the deal with Databinder.Eval and Container.DataItem?
- WinRM不起作用 Connecting to remote server failed with the following error message : WinRM cannot complete the operation
- Failed to compile resources with the following parameters
- Listener refused the connection with the following error:ORA-12505, TNS:listener does not currently
- Dockers Job for docker.service failed because the control process exited with error code
- xxx\Microsoft.Common.targets: error MSB3073: The command xxx exited with code 4
- The following error occurred during schema generation: Unable to load bytecode for class
- [TypeScript] Use the never type to avoid code with dead ends using TypeScript
- DNN报错:The compiler failed with error code 1.