[Mono-list] Simple code - differences in output between mono & .Net

jonathan.cooper@syntegra.com jonathan.cooper@syntegra.com
Wed, 3 Mar 2004 14:31:46 -0000


This is a multi-part message in MIME format.

------_=_NextPart_001_01C4012C.418A80A2
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

I have code (at the end of this message) in a .cs file, compiled with mcs a=
nd
csc on Windows XP. When compiled with either compiler the executable works =
on
both runtimes (.Net and mono). However, the output is different.

Run under .Net:
------------------------
Disk:  A:\
Disk:  C:\
Disk:  D:\
Disk:  K:\
Disk:  L:\
Disk:  Q:\
Disk:  T:\
Disk:  U:\
Disk:  X:\
c:\
Dir:  c:\Compaq
Dir:  c:\Config.Msi
Dir:  c:\Documents and Settings
Dir:  c:\Program Files
Dir:  c:\RECYCLER
Dir:  c:\System Volume Information
Dir:  c:\WINNT


Basically the contents of the root c:\ drive

Run under mono:
--------------------------
Disk:  A:\
Disk:  C:\
c:\
>> a list of directories in the current directory rather than the root c:\ =
<<

Is this due to an incomplete feature, or am I missing something?

Thanks in advance,
Jon Cooper


------------------------ CODE in drives.cs ------------------------

using System;
using System.IO;

namespace test
{=20
   class test
   {
      [STAThread]
      static void Main(string[] args)=20
      {
	 string[] s =3D Directory.GetLogicalDrives();
	 foreach(string drive in s)
	    Console.WriteLine("Disk:  {0}",drive);

	 string mydrive =3D Console.ReadLine();

	 if(mydrive.Length !=3D 0)
	 {
	   foreach(string d in Directory.GetDirectories(mydrive))
	      Console.WriteLine("Dir:  {0}",d);

	   Console.Read();  //pause
	 }
      }
   }
}


********************************************************************

This email may contain information which is privileged or confidential. If =
you are not the intended recipient of this email, please notify the sender =
immediately and delete it without reading, copying, storing, forwarding or =
disclosing its contents to any other person
Thank you

Check us out at http://www.syntegra.com

********************************************************************


------_=_NextPart_001_01C4012C.418A80A2
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3Dus-ascii">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version 6.0.6487.1">
<TITLE>Simple code - differences in output between mono &amp; .Net</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=3D2 FACE=3D"Arial">I have code (at the end of this message) i=
n a .cs file, compiled with mcs and csc on Windows XP. When compiled with e=
ither compiler the executable works on both runtimes (.Net and mono). Howev=
er, the output is different.</FONT></P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Run under .Net:</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">------------------------</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Disk:&nbsp; A:\</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Disk:&nbsp; C:\</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Disk:&nbsp; D:\</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Disk:&nbsp; K:\</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Disk:&nbsp; L:\</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Disk:&nbsp; Q:\</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Disk:&nbsp; T:\</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Disk:&nbsp; U:\</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Disk:&nbsp; X:\</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">c:\</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Dir:&nbsp; c:\Compaq</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Dir:&nbsp; c:\Config.Msi</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Dir:&nbsp; c:\Documents and Settings</FON=
T>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Dir:&nbsp; c:\Program Files</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Dir:&nbsp; c:\RECYCLER</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Dir:&nbsp; c:\System Volume Information</=
FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Dir:&nbsp; c:\WINNT</FONT>
</P>
<BR>

<P><FONT SIZE=3D2 FACE=3D"Arial">Basically the contents of the root c:\ dri=
ve</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Run under mono:</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">--------------------------</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Disk:&nbsp; A:\</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Disk:&nbsp; C:\</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">c:\</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">&gt;&gt; a list of directories in the cur=
rent directory rather than the root c:\ &lt;&lt;</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Is this due to an incomplete feature, or a=
m I missing something?</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Thanks in advance,</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Jon Cooper</FONT>
</P>
<BR>

<P><FONT SIZE=3D2 FACE=3D"Arial">------------------------ CODE in drives.cs=
 ------------------------</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">using System;</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">using System.IO;</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">namespace test</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">{ </FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp; class test</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp; {</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [STAThread=
]</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static voi=
d Main(string[] args) </FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT SIZE=3D2 FACE=3D"=
Arial"> string[] s =3D Directory.GetLogicalDrives();</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT SIZE=3D2 FACE=3D"=
Arial"> foreach(string drive in s)</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 FACE=3D"Arial=
">&nbsp;&nbsp;&nbsp; Console.WriteLine(&quot;Disk:&nbsp; {0}&quot;,drive);<=
/FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT SIZE=3D2 FACE=3D"A=
rial"> string mydrive =3D Console.ReadLine();</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT SIZE=3D2 FACE=3D"A=
rial"> if(mydrive.Length !=3D 0)</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT SIZE=3D2 FACE=3D"=
Arial"> {</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 FACE=3D"Arial=
">&nbsp;&nbsp; foreach(string d in Directory.GetDirectories(mydrive))</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 FACE=3D"Arial=
">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(&quot;Dir:&nbsp; {0}&quo=
t;,d);</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 FACE=3D"Arial"=
>&nbsp;&nbsp; Console.Read();&nbsp; //pause</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT SIZE=3D2 FACE=3D"=
Arial"> }</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp; }</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">}</FONT>
</P>

<CODE><FONT SIZE=3D3><BR>
<BR>
********************************************************************<BR>
<BR>
This email may contain information which is privileged or confidential. If =
you are not the intended recipient of this email, please notify the sender =
immediately and delete it without reading, copying, storing, forwarding or =
disclosing its contents to any other person<BR>
Thank you<BR>
<BR>
Check us out at http://www.syntegra.com<BR>
<BR>
********************************************************************<BR>
</FONT></CODE>
</BODY>
</HTML>
------_=_NextPart_001_01C4012C.418A80A2--