By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,556 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,556 IT Pros & Developers. It's quick & easy.

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

P: n/a
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...
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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" <cm****@yahoo.com> schreef in bericht
news:OZ**************@TK2MSFTNGP09.phx.gbl...
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...
Nov 21 '05 #2

P: n/a
"Chris C" <cm****@yahoo.com> wrote in message
news:OZ**************@TK2MSFTNGP09.phx.gbl...
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.
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.