Re: Newbie question about permissions on network folder

Tech-Archive recommends: Fix windows errors by optimizing your registry



Claudio Gomes wrote:
Hi,

I'm trying to run a pretty simple code to rename a set of files located on a network folder I have access to. When I run this from a local disk it works fine. But when I copy the .EXE to the network and try to run the program from there it comes back with the following exception message:

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

I tried adding the following code:
*-----------------------------------
Dim f As New FileIOPermission(PermissionState.None)
f.AddPathList(FileIOPermissionAccess.AllAccess, "F:\my network folder")
*-------------------------------------


but it made no difference.

The troublesome code goes below:

*------------------------------
Private Sub ChangeFileName(ByVal strFrom As String, ByVal strTo As String, ByRef di As DirectoryInfo, _
ByRef lblStatus As Label)


        Dim entries() As FileSystemInfo
        Try
            entries = di.GetFileSystemInfos(strFrom)

If entries.Length = 1 Then
File.Move(txtPath.Text & entries(0).Name, txtPath.Text & strTo)
lblStatus.Text = "Done"
lblStatus.Visible = True
Else
MsgBox("There was more/less than one file to be renamed from " & strFrom, MsgBoxStyle.OKOnly)
lblStatus.Text = "Unable"
lblStatus.Visible = True
End If


Catch ex As Exception
MsgBox("There was a problem trying to access the directory " & txtPath.Text & vbCrLf & _
"The message was: " & vbCrLf & ex.Message, _
MsgBoxStyle.OKOnly & MsgBoxStyle.Exclamation)
lblStatus.Text = "Unable"
lblStatus.Visible = True
End Try
End Sub

You are having issues with security. If you goto Accessories -> Dot Net Security Wizard you can adjust you the settings for your app. Put it fully trusted and you'll see that it works. If you need to depoly this app you'll have to look into security profiles and such for deploying your app.


Good luck
Chris
.



Relevant Pages

  • Network access
    ... I have an Access VBA app on a network folder that I'd like to run simultaneously by multiple users. ... I can run one instance over the network, but not two at once, unless the second instance is from the folder in which the app resides. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Open files with a variable name in a folder get name in B1 and
    ... Your ability manually to rename a file from ... the network folder confirms your permissions. ...
    (microsoft.public.excel.programming)
  • Re: Open files with a variable name in a folder get name in B1 and
    ... Both are working for me in my private network Norman ... Your ability manually to rename a file from ... the network folder confirms your permissions. ...
    (microsoft.public.excel.programming)
  • Re: ODBC Connection with SQL Managed Provider
    ... One thing to remember is when running application from a network share, ... > So it was our intent to put a lot of the "forms" into the main app. ... the odbc manager is no quicker than the odbc. ... >>> authorizing the user against a table in the SQL server database. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: .NET new executable
    ... Since there is no network access avaialble, I want to send my app to each ... then you update the data into database. ... If all you are trying to do is send some data to your SQL server, ...
    (microsoft.public.dotnet.general)