Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. System.Security File I/O problem

System.Security File I/O problem

Scheduled Pinned Locked Moved C#
csharphelpdotnetsecurity
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paul Griffin
    wrote on last edited by
    #1

    Hi all, i've developed a c# windows application that envolves file I/O. Up to now all development has been on my own machine running win2k pro and i am logged in as an administrator. I recently tried running the code on another machine on which i installed the .net redistributable and as soon as the app tried to access the file system (i.e when opening a file dialog) it through an exception of the type System.Security.FileIOPermissions. I've looked into it a bit and discovered how the clr assigns permissions to different assemblies at runtime etc. What i'd like to know is, is there a way for me to configure my code so that it can always access the file system on other machines... i don't want the user to have to manually increase the trust level using the .net config tool as that would be very messy!! any help is appreciated Thanks Paul Paul Griffin

    A 1 Reply Last reply
    0
    • P Paul Griffin

      Hi all, i've developed a c# windows application that envolves file I/O. Up to now all development has been on my own machine running win2k pro and i am logged in as an administrator. I recently tried running the code on another machine on which i installed the .net redistributable and as soon as the app tried to access the file system (i.e when opening a file dialog) it through an exception of the type System.Security.FileIOPermissions. I've looked into it a bit and discovered how the clr assigns permissions to different assemblies at runtime etc. What i'd like to know is, is there a way for me to configure my code so that it can always access the file system on other machines... i don't want the user to have to manually increase the trust level using the .net config tool as that would be very messy!! any help is appreciated Thanks Paul Paul Griffin

      A Offline
      A Offline
      apferreira
      wrote on last edited by
      #2

      NET security was design for apps not to have blind access to resources in user's computers. So the default behaviour is for your program to be able to do only what the user machine allows. Consequently, when designing your programs you have two options: 1.Use declarative security syntax (for running your program requires...so if that permission is not there the program will not run. You may add a messagebox informing the user why.) 2.Use isolated storage. Isolated storage enables partially trusted apps to store data in a way that is controlled by the computer's security policy. Altering the previleges yourself would be against NET's security framework, which is based on the premiss that it is the user that decides what permissions are given to what programs.

      P 1 Reply Last reply
      0
      • A apferreira

        NET security was design for apps not to have blind access to resources in user's computers. So the default behaviour is for your program to be able to do only what the user machine allows. Consequently, when designing your programs you have two options: 1.Use declarative security syntax (for running your program requires...so if that permission is not there the program will not run. You may add a messagebox informing the user why.) 2.Use isolated storage. Isolated storage enables partially trusted apps to store data in a way that is controlled by the computer's security policy. Altering the previleges yourself would be against NET's security framework, which is based on the premiss that it is the user that decides what permissions are given to what programs.

        P Offline
        P Offline
        Paul Griffin
        wrote on last edited by
        #3

        Does this mean that at best all i could do is inform the user that the need to run the .net config tool and increase the trust level of the app?? or can i programmtically config my app so that it can access tyhe file system if i give it the correct permissions Paul Griffin

        A 1 Reply Last reply
        0
        • P Paul Griffin

          Does this mean that at best all i could do is inform the user that the need to run the .net config tool and increase the trust level of the app?? or can i programmtically config my app so that it can access tyhe file system if i give it the correct permissions Paul Griffin

          A Offline
          A Offline
          apferreira
          wrote on last edited by
          #4

          You do not give security permissions in NET code. You ask the user's computer for a specific permission. If the answer is negative you have the following options: 1. Continue to run the program with limited functionality. 2. Stop the program. 3. Use isolated storage as a workaround (like i said in my last post isolated enables partially trusted apps (i.e, apps that do not have all the permissions) to store data in a way that is controlled by the computer's security policy)

          P 1 Reply Last reply
          0
          • A apferreira

            You do not give security permissions in NET code. You ask the user's computer for a specific permission. If the answer is negative you have the following options: 1. Continue to run the program with limited functionality. 2. Stop the program. 3. Use isolated storage as a workaround (like i said in my last post isolated enables partially trusted apps (i.e, apps that do not have all the permissions) to store data in a way that is controlled by the computer's security policy)

            P Offline
            P Offline
            Paul Griffin
            wrote on last edited by
            #5

            Thanks for the info, i'll take a look into isolated storage then!! Paul Griffin

            P 1 Reply Last reply
            0
            • P Paul Griffin

              Thanks for the info, i'll take a look into isolated storage then!! Paul Griffin

              P Offline
              P Offline
              Paul Griffin
              wrote on last edited by
              #6

              is it possible to use the common file dialog boxes (SaveFileDialog, OpenFileDialog etc) with the IsolatedStorageFileStream??? Paul Griffin

              J 1 Reply Last reply
              0
              • P Paul Griffin

                is it possible to use the common file dialog boxes (SaveFileDialog, OpenFileDialog etc) with the IsolatedStorageFileStream??? Paul Griffin

                J Offline
                J Offline
                Josh Martin
                wrote on last edited by
                #7

                What I have found in my development is that if the application is installed locally on the user's machine, it works fine (can access the file system). It's only when they try to run the program from a network share that they get the security error. Josh Find a penny, pick it up, and all day long you'll have a back-ache...

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups