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. FileIOPermission Problem

FileIOPermission Problem

Scheduled Pinned Locked Moved C#
helpdebuggingquestion
2 Posts 1 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.
  • O Offline
    O Offline
    Okultist
    wrote on last edited by
    #1

    Good Evening, currently I am doing a small program which copies a file from one folder to another folder. The destination folder is the "Fonts" folder which holds all fonts of my system. Currently my code looks like this:

    FileIOPermission f2 = new FileIOPermission(FileIOPermissionAccess.Write, "C:\\Windows\\Fonts\\");
    f2.AddPathList(FileIOPermissionAccess.Read , origin);

     try
     {
          System.IO.File.Copy(origin, destination);
     }
     catch (UnauthorizedAccessException ex)
     {
           MessageBox.Show(ex.ToString());
     }
    

    When I start debugging, the debugger tells me that I dont have permission for C:\Windows\Fonts\"filename". Which confuses me a bit since I thought I already got write permission to "C:\Windows\Fonts\". What am i doing wrong? P.S.: I am using Windows Vista SP1 64-Bit Thanks for your help and advices

    O 1 Reply Last reply
    0
    • O Okultist

      Good Evening, currently I am doing a small program which copies a file from one folder to another folder. The destination folder is the "Fonts" folder which holds all fonts of my system. Currently my code looks like this:

      FileIOPermission f2 = new FileIOPermission(FileIOPermissionAccess.Write, "C:\\Windows\\Fonts\\");
      f2.AddPathList(FileIOPermissionAccess.Read , origin);

       try
       {
            System.IO.File.Copy(origin, destination);
       }
       catch (UnauthorizedAccessException ex)
       {
             MessageBox.Show(ex.ToString());
       }
      

      When I start debugging, the debugger tells me that I dont have permission for C:\Windows\Fonts\"filename". Which confuses me a bit since I thought I already got write permission to "C:\Windows\Fonts\". What am i doing wrong? P.S.: I am using Windows Vista SP1 64-Bit Thanks for your help and advices

      O Offline
      O Offline
      Okultist
      wrote on last edited by
      #2

      Can someone give me some help on this please, since i dont know what i am doing wrong? I used a messagebox to have a quick look at the permmission i requested and it says i asked for write permission for C:\Windows\Fonts and read permission for the folder in "origin". Is there something else I have to do?

      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