Home All Groups Group Topic Archive Search About

Total VB.Net newbie - Directory.Exists question

Author
11 Apr 2006 9:49 AM
ginolard
Dim b As Boolean
        b = System.IO.Directory.Exists("c:\temp")
        MsgBox(b)

Could someone explain why that returns FALSE when c:\temp quite
evidently exists?

Author
11 Apr 2006 10:00 AM
Patrice
Works here. What if you try to perform some oprations on this dir ? (such as
counting files, writing down a file or reading a file) ?

--
Patrice

<ginol***@gmail.com> a écrit dans le message de news:
1144748986.982079.226***@v46g2000cwv.googlegroups.com...
Show quoteHide quote
>        Dim b As Boolean
>        b = System.IO.Directory.Exists("c:\temp")
>        MsgBox(b)
>
> Could someone explain why that returns FALSE when c:\temp quite
> evidently exists?
>
Author
11 Apr 2006 10:14 AM
ginolard
Bizarrely, if I try to use fileContents =
System.IO.File.ReadAllText("C:\temp\input.txt") I get a "Security
error" with the following message

Request for the permission of type
'System.Security.Permissions.FileIOPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
failed.

Again, that's odd as I'm admin of my machine and the directory has Full
Control for Everyone.
Author
11 Apr 2006 10:55 AM
ginolard
Ah well, I guess am learning slowly.  It seems that the problems are
caused because my project resides (and therefore runs from) a network
drive.  When I save it and run it from C:, it works as expected.

How do you resolve this little problem?
Author
11 Apr 2006 11:03 AM
Herfried K. Wagner [MVP]
<ginol***@gmail.com> schrieb:
> Ah well, I guess am learning slowly.  It seems that the problems are
> caused because my project resides (and therefore runs from) a network
> drive.  When I save it and run it from C:, it works as expected.

You'll have to trust the application:

<URL:http://groups.google.de/group/microsoft.public.dotnet.languages.vb/msg/1858a28b202f3f31>

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
11 Apr 2006 11:42 AM
ginolard
What, Visual Studio 2005 Express itself or my project?  I presume I can
also do this via the .Net 2.0 Config Utility wizard (although how is
another matter entirely)
Author
11 Apr 2006 1:00 PM
Patrice
Your application. The .NET Framework handles Code Access Security i.e. the
code is not allowed to perform necessarery all actions in particular
depending on its location. In VS 2005, you should have a dialog to do that
automatically when you build...

--
Patrice

<ginol***@gmail.com> a écrit dans le message de news:
1144755723.323722.317***@j33g2000cwa.googlegroups.com...
Show quoteHide quote
> What, Visual Studio 2005 Express itself or my project?  I presume I can
> also do this via the .Net 2.0 Config Utility wizard (although how is
> another matter entirely)
>
Author
11 Apr 2006 3:45 PM
ginolard
Hmm.  When I select Build Application it just completes with a Build
Succeeded message.   Sorry for asking what are probably totally dumb
questions but I only installed VS 2005 Express yesterday and started
playing with it today ;)
Author
11 Apr 2006 4:29 PM
Patrice
In "Project properties" do you have a "Security" tab ? (translated from
French). It allows to tell which security should be applied to the ClickOnce
application.

If you don't have this in Express, you could configure manually using the
control panel applet. The applet allows to create an MSI file to install
this same policy on other PCs.

The big picture may help (for example instead of dealing with c:\temp the
application could perhaps use the "isolated storage")
--

<ginol***@gmail.com> a écrit dans le message de news:
1144770324.305405.121***@j33g2000cwa.googlegroups.com...
Show quoteHide quote
> Hmm.  When I select Build Application it just completes with a Build
> Succeeded message.   Sorry for asking what are probably totally dumb
> questions but I only installed VS 2005 Express yesterday and started
> playing with it today ;)
>
Author
12 Apr 2006 6:35 AM
ginolard
Sigh....how simple was that in the end?  Yes, there is a security tab
and I enabled Clickonce Security Settings and set FileIOPermission to
Include.  Sure enough, all now works as expected.

Thank you for your help and patience.
Author
11 Apr 2006 10:00 AM
ginolard
Odd.  in Visual Studio 2005 Express this code returns FALSE.  In the
full version of Visual Studio 2005 it returns TRUE.