469,342 Members | 5,574 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,342 developers. It's quick & easy.

Access to Path is Denied.

I am getting a dreaded Access To Path <fileis 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
peertATenvysysDOTcomNothingElseFollowsThisEmailAdd ress.

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);

}


Jun 6 '07 #1
5 25195

"Tim Peer" <Pe***@envysys.comwrote in message
news:eg**************@TK2MSFTNGP02.phx.gbl...
>I am getting a dreaded Access To Path <fileis 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.

Jun 6 '07 #2
On Jun 6, 1:39 pm, "Mr. Arnold" <MR. Arn...@Arnold.comwrote:
"Tim Peer" <P...@envysys.comwrote in message

news:eg**************@TK2MSFTNGP02.phx.gbl...
I am getting a dreaded Access To Path <fileis 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.
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.

Jun 6 '07 #3
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

Jun 6 '07 #4

"Tim Peer" <Pe***@envysys.comwrote in message
news:uG**************@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.
>
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.
Maybe, the link will help you pin point what is happening.

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

Jun 7 '07 #5
On Jun 7, 8:34 am, "Mr. Arnold" <MR. Arn...@Arnold.comwrote:
"Tim Peer" <P...@envysys.comwrote in message

news:uG**************@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.


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.

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

http://www.codeproject.com/dotnet/UB_CAS_NET.asp- Hide quoted text -

- Show quoted text -
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.

Jun 7 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Luiz Vianna | last post: by
1 post views Thread by Brian Bischof | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.