469,658 Members | 1,855 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,658 developers. It's quick & easy.

Using the System.IO.Directory services...

I am very new to vb.net and am using Visual Basic 2005 Express Edition.

This is my function that essentially looks at a directory to see if it
is valid:

'Local variables
Dim sDirectory As System.IO.Directory

'See if path is valid
If sDirectory.Exists(Me.txtFilePath.Text) Then
FillList()
Else
Me.lstFoundFiles.Items.Clear()
End If

This works fine but I am confused by the warning messages I am getting:

Warning 1 - Unused local variable: 'sDirectory'.
Warning 2 - Access of shared member, constant member, enum member or
nested type through an instance; qualifying expression will not be
evaluated.

Now the local variable is being used and appears to be working because
when my text box (txtFilePath) is invalid the list is cleared and when
it is valid my FillList method is called. I am not sure what Warning 2
means.

Can anyone shed a little light on this?

Feb 22 '06 #1
4 3905
you are getting the first warning because it is using the IO.Directory (class
maybe?...dunno if thats a class or object) to check if the directory exists,
not your variable. you can simply use

if IO.Directory(MyDirectoryHere) then

....

end if

and that will clear the first warning

what line is the second warning on?
--
-iwdu15
Feb 23 '06 #2
adam,

Exists is a shared method of the Directory class, so you don't need an
instance variable to access the method:

If Directory.Exists ...

Kerry Moorman
"ad***********@gmail.com" wrote:
I am very new to vb.net and am using Visual Basic 2005 Express Edition.

This is my function that essentially looks at a directory to see if it
is valid:

'Local variables
Dim sDirectory As System.IO.Directory

'See if path is valid
If sDirectory.Exists(Me.txtFilePath.Text) Then
FillList()
Else
Me.lstFoundFiles.Items.Clear()
End If

This works fine but I am confused by the warning messages I am getting:

Warning 1 - Unused local variable: 'sDirectory'.
Warning 2 - Access of shared member, constant member, enum member or
nested type through an instance; qualifying expression will not be
evaluated.

Now the local variable is being used and appears to be working because
when my text box (txtFilePath) is invalid the list is cleared and when
it is valid my FillList method is called. I am not sure what Warning 2
means.

Can anyone shed a little light on this?

Feb 23 '06 #3
Ah, I get it now. Kind of like a singleton which is always
instantiated.

Thanks for the help!

Feb 23 '06 #4
Ah, I get it now. Kind of like a singleton which is always
instantiated.

Thanks for the help!

Feb 23 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Rich Milburn [MVP] | last post: by
3 posts views Thread by Jay-nospam | last post: by
1 post views Thread by Screenbert | last post: by
2 posts views Thread by =?Utf-8?B?TmFt?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.