I'm new to the group, first post ever (woo!). Previously I've used
some Yahoo groups for ASP programming help and they were really really
helpful so I hope everyone here is just as handy.
Down to the small challenge I'm facing. I'm trying to write a tiny
little basic program which will quickly rename entire directories of
files in a single bound.
I decided that it'd be worthwhile verifying that the path typed into
the txtLocation textbox, is actually a valid path using the
'My.Computer.FileSystem.DirectoryExists' method. No matter what I do,
the response I get is 'False' even though I am 100% certain that the
directory exists. I also get the same result with the FileExists
method.
Here's the code I'm using for FileExists:
If My.Computer.FileSystem.FileExists("C:\setup.txt") Then
MsgBox("File found.")
Else
MsgBox("File not found.")
End If
I copied and pasted that from MSDN, so you'd think that'd work!
Can anyone give me some pointers or tell me where I've gone wrong?
Many thanks,
Scott.
Firstly, Welcome to the group. I hope you have a great time here... ;-)
As for your question, if you've made sure that the file and directory
that you are querying for, do actually exist on the drive, then it is
quite possible that the reason the method always returns a False value
is that you don't have the FileIOPermission on the said directory /
file. The Remarks section of the Language reference for this method
clearly mentions this.
See <http://msdn2.microsoft.com/en-gb/library/yd267cce(VS.80).aspx> for
information about requesting permissions.
Hope this helps,
Cerebrus.