473,385 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 4029
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sivaraman.S | last post by:
I am unable to create new users using directory services in Windows 2003 server. But it is possible to create users with ASP.NET applications in windows 2000. I am getting "Permission Denied"...
22
by: EP | last post by:
When running my asp.net hosting service (asp.net without IIS), on server 2003 with IIS not installed, I get the following when trying to process a request. "System.DllNotFoundException: Unable to...
4
by: Matthew Roche | last post by:
Greetings: I am developing an application that uses an ASP.NET Web Forms application for its UI and ASP.NET web services for its business tier, and I am looking for assistance in improving my...
7
by: Rich Milburn [MVP] | last post by:
Ok I am not a programmer, I copied some code and very painfully got it working in VB6. I can adjust the volume with waveOutSetVolume on winmm.dll. But I could not seem to be able to figure out how...
3
by: Jay-nospam | last post by:
Hi there, I am having trouble getting an ASP.NET web application to connect to another computer and passing the proper credentials and I hope someone can help me. I have a stand-alone Windows...
1
by: Screenbert | last post by:
After finding nothing anywhere in google I am posting this so everyone can benefit by it. The formating is not pretty since I copied it from my word document, but you should benefit by it. ...
0
by: screenbert | last post by:
Managing DHCP Servers using C# They said it was impossible. It couldn't be done. But you can in fact manage DHCP servers using C#. This includes creating and deleting Scopes, SuperScopes,...
0
by: =?Utf-8?B?TWFuaQ==?= | last post by:
Hi All, Problem in deploying my WebService developed using Asp.net WebServices 2005. I have designed simple WebService using Asp.net Webservices 2.0 , The webservice look this , using System;...
2
by: =?Utf-8?B?TmFt?= | last post by:
On my ASP.NET 2.0 website project on VS 2005, I am getting the following error when building the solution: “The type or namespace name 'ADSI' does not exist in the namespace 'myNameSpace' (are...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.