Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C# Programming

Access to Path is Denied.


I am getting a dreaded Access To Path <file> is denied in a C# program. I
tried granting full access to ASPNET (local machine), the user running the
program (a domain administrator) and continue to get the error everytime I
attempt to access the file, create a new file or delete the file. I even
attempted to set fileIOPermission to what I believe to be all access for the
file and the directory with the same result.

Any advise would be greatly appreciated!

Tim
peertATenvysysDOTcomNothingElseFollowsThisEmailAddress.

System.IO.FileInfo finfo = new System.IO.FileInfo(ffile);

FileIOPermission fper = new
FileIOPermission(FileIOPermissionAccess.AllAccess,finfo.Directory.FullName) ;

//finfo.Attributes = FileAttributes.Normal;

if (!finfo.Exists) finfo.Create();

}

catch (Exception ec)

{

DevExpress.XtraEditors.XtraMessageBox.Show(this, ec.Message);

"Tim Peer" <P @envysys.com> wrote in message

news:egSuOC$pHHA.3368@TK2MSFTNGP02.phx.gbl ...

>I am getting a dreaded Access To Path <file> is denied in a C# program. I
>tried granting full access to ASPNET (local machine), the user running the
>program (a domain administrator) and continue to get the error everytime I
>attempt to access the file, create a new file or delete the file. I even
>attempted to set fileIOPermission to what I believe to be all access for
>the file and the directory with the same result.

> Any advise would be greatly appreciated!

If this is on a Share, then you might want  to check permissions on the
Share as opposed to permissions for a file or directory in the Share. User
account can have full permissions on the directory or file in a directory,
but permissions on the Share itself for the User account may not have those
rights, is not there or another account, like group account Everyone, as an
example,  is superseding all rights on the Share.

-----------------------------------------------Reply-----------------------------------------------
On Jun 6, 1:39 pm, "Mr. Arnold" <MR. Arn @Arnold.com> wrote:

Seems to be a problem with permission. Usually Access Denied will
occur due to two reasons 1)Insufficient permissions. 2)File is being
used because stream was not properly closed/disposed.

-----------------------------------------------Reply-----------------------------------------------
Thank you Aneesh and Mr. Arnold,

I am attempting to create the file on a disk on the local system. The
username of the account running the C# program should have adequate privs
since it is in the administrators group. I have altered permissions on the
login (domain) user account, ASPNET local user account and no luck. It was
mentioned I might have an open stream on the file, I don't think this is the
case since I am creating a new file and SYSTEM.IO activity is limited to
this single method.

  System.IO.FileInfo finfo = new System.IO.FileInfo(ffile);

  if (!finfo.Exists) finfo.Create();

Do you know within which account the .NET 2.0 application executes. From
what I can see, my account being in the administrators group should not
raise this violation, but should the application execute from an account
proxy...

Also, I read that the USERS group is used by .NET application when such
errors occur but do not have a USERS group in Small Business Server 2003.

Thanks again for your help with this.

Tim

-----------------------------------------------Reply-----------------------------------------------

"Tim Peer" <P< a target=_parent href="#70e4652a36999944&_done=/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/06813dfcc3788cb4"> @envysys.com> wrote in message

news:uGEVJrHqHHA.4196@TK2MSFTNGP06.phx.gbl...

> Thank you Aneesh and Mr. Arnold,

> I am attempting to create the file on a disk on the local system. The
> username of the account running the C# program should have adequate privs
> since it is in the administrators group. I have altered permissions on the
> login (domain) user account, ASPNET local user account and no luck. It was
> mentioned I might have an open stream on the file, I don't think this is
> the case since I am creating a new file and SYSTEM.IO activity is limited
> to this single method.

I believe the machine/ASPNET account only comes into play for the ASP.NET
Worker Process and what permissions it has, such as permissions an ASP.NET
solution would have in a browser session to work with directory/files.

Maybe, the link will help you pin point what is happening.

http://www.codeproject.com/dotnet/UB_CAS_NET.asp

-----------------------------------------------Reply-----------------------------------------------

On Jun 7, 8:34 am, "Mr. Arnold" <MR. Arn @Arnold.com> wrote:

Just check the username for current thread using
System.Environment.UserDomainName + @"\" +
System.Environment.UserName, just before creating file.
And once you have the username then check the permissions.
 
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc