I think I understand now. If I want to see the result, then nothing has
changed. I still need to use Debug.Write instead of Console.Write. I
generally debug in the environment. I am greatly anticipating the
improvement that will come with VS 2005. Meanwhile, I stop the IDE, examine
the object's properties and make guesses as to what the code should look
like. Who has the time to compile and then run?
Thanks for your answer Peter.
--
Regards,
Jamie
[quoted text, click to view] "Peter van der Goes" wrote:
>
> "thejamie" <thejamie@discussions.microsoft.com> wrote in message
> news:2C89F888-B6C2-4FD6-A075-58E7B3D74318@microsoft.com...
> >I am trying to see the results that occur when using a line such as
> > Console.WriteLine
> >
> > The sample below comes directly from the Microsoft Help on GetFiles. I
> > cannot figure out where the Console.Writeline information is viewable. If
> > I
> > am not supposed to see it then why doesn't the example use debug.write
> > instead of Console.WriteLine?
> >
> > Imports System
> > Imports System.IO
> >
> > Public Class Test
> > Public Shared Sub Main()
> > Try
> > Dim di As DirectoryInfo = New DirectoryInfo("c:\")
> > 'Get only subdirectories that contain the letter "p."
> > Dim dirs As DirectoryInfo() = di.GetDirectories("*p*")
> > Console.WriteLine("Number of directories with a p: {0}",
> > dirs.Length)
> > Dim diNext As DirectoryInfo
> > ' Count all files in each subdirectory that contain the letter
> > "e."
> > For Each diNext In dirs
> > Console.WriteLine("The number of files in {0} with an e is
> > {1}", _
> > diNext, diNext.GetFiles("*e*").Length)
> > Next
> >
> > Catch e As Exception
> > Console.WriteLine("The process failed: {0}", e.ToString())
> > End Try
> > End Sub
> > End Class
> >
> > --
> > Regards,
> > Jamie
>
> What template did you use for the project? If you use a VB Console project
> and substitute the code you quoted for the boilerplate code, it compiles and
> displays the output in the console window.
>
> --
> Peter [MVP Visual Developer]
> Jack of all trades, master of none.
>
>
I was actually looking for a good FileExists routine. Managed to create my
own. Listing below if needed by anyone:
Public Function FileExists(ByVal strPathName As String) As Short
'Dim bFind As System.IO.DirectoryInfo.GetFiles
Dim sDir As String
Dim nI As Integer
Const DirSep = "\"
Dim folders() As String
Dim file As System.IO.FileInfo
'Break up the file name
folders = Split(strPathName, DirSep, -1)
'build the directory
For nI = 0 To UBound(folders) - 1
sDir = sDir & folders(nI) & DirSep
Next
Dim dirs As New System.IO.DirectoryInfo(sDir)
Dim files() As System.io.FileInfo = dirs.GetFiles("*.*")
'get the files that match the parameters
files = dirs.GetFiles(folders(UBound(folders)))
'check for a match
If Not (files Is Nothing) Then
For Each file In files
If LCase(file.FullName) = LCase(strPathName) Then
FileExists = True
Exit For
End If
Next
End If
End Function
--
Regards,
Jamie
[quoted text, click to view] "thejamie" <thejamie@discussions.microsoft.com> wrote in message
news:2C89F888-B6C2-4FD6-A075-58E7B3D74318@microsoft.com...
>I am trying to see the results that occur when using a line such as
> Console.WriteLine
>
> The sample below comes directly from the Microsoft Help on GetFiles. I
> cannot figure out where the Console.Writeline information is viewable. If
> I
> am not supposed to see it then why doesn't the example use debug.write
> instead of Console.WriteLine?
>
> Imports System
> Imports System.IO
>
> Public Class Test
> Public Shared Sub Main()
> Try
> Dim di As DirectoryInfo = New DirectoryInfo("c:\")
> 'Get only subdirectories that contain the letter "p."
> Dim dirs As DirectoryInfo() = di.GetDirectories("*p*")
> Console.WriteLine("Number of directories with a p: {0}",
> dirs.Length)
> Dim diNext As DirectoryInfo
> ' Count all files in each subdirectory that contain the letter
> "e."
> For Each diNext In dirs
> Console.WriteLine("The number of files in {0} with an e is
> {1}", _
> diNext, diNext.GetFiles("*e*").Length)
> Next
>
> Catch e As Exception
> Console.WriteLine("The process failed: {0}", e.ToString())
> End Try
> End Sub
> End Class
>
> --
> Regards,
> Jamie
What template did you use for the project? If you use a VB Console project
and substitute the code you quoted for the boilerplate code, it compiles and
displays the output in the console window.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.