[Mono-list] FileInfo.Exists() returns false after calling FileInfo.Create()

Rathna N NRathna@novell.com
Thu, 29 Jan 2004 07:22:07 -0700


This is a MIME message. If you are reading this text, you may want to 
consider changing to a mail reader or gateway that understands how to 
properly handle MIME multipart messages.

--=__Part39186D1F.0__=
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Hi, 
FileInfo.Exists() returns false in the below scenario.
 
1. FileInfo info = new FileInfo (path);
2. AssertEquals ("test#01", false, info.Exists); //--> returns "false"
3. info.Create();
4.  AssertEquals ("Exits - test#02", true, info.Exists); //--> returns
"false"

 
is this the expected behavior ?
 
 
CODE SNIPPET:
 
[Test]
  public void Read(){
string TempFolder = Path.Combine (Path.GetTempPath (),
"MonoTests.System.IO.Tests");
   string path = TempFolder + "/FA.Read.Test";
   DeleteFile (path);  
   
   try 
   {
    
    FileInfo info = new FileInfo (path);
    AssertEquals ("test#01", false, info.Exists);
    info.Create();
    AssertEquals ("Exits - test#02", true, info.Exists);
    FileStream fStream = info.Open(FileMode.Open,FileAccess.Read);    
    AssertEquals ("test#03", true, fStream.CanRead);
    AssertEquals ("test#04", false, fStream.CanWrite);
    AssertEquals ("test#05", true, fStream.CanSeek);
    fStream.Close();
   }  
   finally 
   {
    DeleteFile (path);
   }
  }      
 
 
thanks,
Rathna.

--=__Part39186D1F.0__=
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-2022-jp">
<META content="MSHTML 6.00.2800.1276" name=GENERATOR></HEAD>
<BODY style="MARGIN: 4px 4px 1px; FONT: 10pt Microsoft Sans Serif">
<DIV>Hi, </DIV>
<DIV>FileInfo.Exists() returns false in the below scenario.</DIV>
<DIV>&nbsp;</DIV>
<DIV>1.&nbsp;FileInfo info = new FileInfo (path);<BR>2. AssertEquals ("test#01", false, info.Exists); //--&gt; returns "false"<BR>3. info.Create();<BR>4.&nbsp;&nbsp;AssertEquals ("Exits - test#02", true, info.Exists); //--&gt; returns "false"<BR></DIV>
<DIV>&nbsp;</DIV>
<DIV>is this the expected behavior ?</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>CODE SNIPPET:</DIV>
<DIV>&nbsp;</DIV>
<DIV>[Test]<BR>&nbsp;&nbsp;public void Read(){</DIV>
<DIV>string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.IO.Tests");<BR>&nbsp;&nbsp;&nbsp;string path = TempFolder + "/FA.Read.Test";<BR>&nbsp;&nbsp;&nbsp;DeleteFile (path);&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;try <BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;FileInfo info = new FileInfo (path);<BR>&nbsp;&nbsp;&nbsp;&nbsp;AssertEquals ("test#01", false, info.Exists);<BR>&nbsp;&nbsp;&nbsp;&nbsp;info.Create();<BR>&nbsp;&nbsp;&nbsp;&nbsp;AssertEquals ("Exits - test#02", true, info.Exists);<BR>&nbsp;&nbsp;&nbsp;&nbsp;FileStream fStream = info.Open(FileMode.Open,FileAccess.Read);&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;AssertEquals ("test#03", true, fStream.CanRead);<BR>&nbsp;&nbsp;&nbsp;&nbsp;AssertEquals ("test#04", false, fStream.CanWrite);<BR>&nbsp;&nbsp;&nbsp;&nbsp;AssertEquals ("test#05", true, fStream.CanSeek);<BR>&nbsp;&nbsp;&nbsp;&nbsp;fStream.Close();<BR>&nbsp;&nbsp;&nbsp;}&nbsp; <BR>&nbsp;&nbsp;&nbsp;finally <BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;DeleteFile (path);<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>thanks,</DIV>
<DIV>Rathna.</DIV></BODY></HTML>
--=__Part39186D1F.0__=--