What's wrong with the following code?

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.










转载于:https://www.cnblogs.com/zsgcjys/archive/2005/01/14/91904.html

你可能感兴趣的:(What's wrong with the following code?)