I am trying to write to a text file using VB.NET, I have used the code as explained in a book called "Professional VB.NET" and also on a website. However I still get Permission errors.

The part of my code that deals with granting the permissions, opening the file for append and then adding to the file is shown below:

Dim FilePermission As FileIOPermission = New FileIOPermission(FileIOPermissionAccess.AllAccess,
"C:\Inetpub\wwwroot\temp\pickfile2.lst")
FilePermission.Assert()
Try
Dim writer1 As New StreamWriter(File.Open("C:\Inetpub\wwwroot\temp\pickfile2.lst",
FileMode.Append))
writer1.WriteLine(Store.BoxID(Store.BoxNo) & "," & Store.OldLoc(Store.BoxNo)
& "," & Store.NewLoc(Store.BoxNo))
writer1.Close()
Catch objA As System.Exception
MessageBox.Show(objA.Message)
End Try


However when I run this code I get the following error:

Request for the permission of type System.Security.Permissions.FileIOPermission,
mscorlib, Version=1.0.3300.0, Culture=netural, PublicKeyToken=b77a5c561934e089
failed.



__________________
David Bradley
[email protected]