UnauthorizedAccessException in debug mode only?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy

    UnauthorizedAccessException in debug mode only?

    Hi,

    Using VS2008, .Net 3.5.

    I have a File.Copy which is copying files to a unc path. The copying
    is done by a normal Wpf application. Suddenly, trying to copy the
    web.config to the unc path fails. So does File.Delete, although I
    have no problems deleting the file via Explorer. Even more curious,
    if I switch the build configuration to Release, it works fine. So it
    only seems to happen in Debug mode.

    Any ideas? Just want to restate, this is a Wpf application NOT
    running under Asp.Net or a service account; it's running as me with my
    WindowsPrincipa l set on the executing thread.

    Thanks
    Andy
  • Andy

    #2
    Re: UnauthorizedAcc essException in debug mode only?

    Ok, I found the problem.. the target file had the ReadOnly flag set.
    Code that unsets it prior to copying solves the issue.

    On May 13, 4:19 pm, Andy <an...@med-associates.comw rote:
    Hi,
    >
    Using VS2008, .Net 3.5.
    >
    I have a File.Copy which is copying files to a unc path. The copying
    is done by a normal Wpf application. Suddenly, trying to copy the
    web.config to the unc path fails. So does File.Delete, although I
    have no problems deleting the file via Explorer. Even more curious,
    if I switch the build configuration to Release, it works fine. So it
    only seems to happen in Debug mode.
    >
    Any ideas? Just want to restate, this is a Wpf application NOT
    running under Asp.Net or a service account; it's running as me with my
    WindowsPrincipa l set on the executing thread.
    >
    Thanks
    Andy

    Comment

    Working...