IO-statements do not execute on network-drive ???

C

cmrchs

Hi,

executing the following on a local drive works fine :

FileStream wLog = File.OpenRead("c:\Log.txt")
FileStream wLog = File.OpenRead("h:\Log.txt")

but executing the same code on a network drive creates a FileIOPermission-exception.
although the user has full control on the drive where the application is running.
Actually, any IO-statement creates an exception ???

Is it some kind of .NET permission that must be set or something else ?

any help greatly appreciated !!

thanks
Chris

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
P

Peter Proost

Hi have you tried it like this \\server\share\file

else try this example:
Try
Dim xAs New System.IO.StreamReader(\\server\share\Log.txt,
IO.FileMode.Open)
Dim line As String
Do
line = x.ReadLine()
TextBox2.Text &= line & vbCrLf
Loop Until line Is Nothing
x.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try

hth Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

Chris C said:
Hi,

executing the following on a local drive works fine :

FileStream wLog = File.OpenRead("c:\Log.txt")
FileStream wLog = File.OpenRead("h:\Log.txt")

but executing the same code on a network drive creates a FileIOPermission-exception.
although the user has full control on the drive where the application is running.
Actually, any IO-statement creates an exception ???

Is it some kind of .NET permission that must be set or something else ?

any help greatly appreciated !!

thanks
Chris

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP &
ASP.NET resources...
 
P

Phill. W

Chris C said:
executing the following on a local drive works fine :

FileStream wLog = File.OpenRead("c:\Log.txt")
FileStream wLog = File.OpenRead("h:\Log.txt")
but executing the same code on a network drive creates a
FileIOPermission-exception. although the user has full control
on the drive where the application is running.

The /user/ might have, but the .Net Framework is more particular.
Is it some kind of .NET permission that must be set ... ?

Yes.
You need to set up Code Access Security Policies on your machine
to allow code executed /from/ your network share to run.
By default, the Framework sees /no difference/ between running code
form your network share and (the ficticious (I hope))
www.NastyMaliciousAndDownrightDodgySoftware.com.

Read up on caspol.exe and mscorcfg.msc.

Regards,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top