您的位置:首页 > 其它

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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: