Visual Basic .NET Forums  

Go Back   Visual Basic .NET Forums > VB.NET > Security

Security Discussion on securing VB.NET applications, end-user configuration, application activation, etc.

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-29-2008, 5:54 AM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Nov 2008
Age: 31
Posts: 4
Reputation: 0
sanjoydas is on a distinguished programming path ahead
Default Attempted to perform an unauthorized operation - Error message on Delete a File

Attempted to perform an unauthorized operation. - Error is showing on delete a File in Windows Vista OS. The following code is used with windows Application -
Code:
Dim fInfo As New FileInfo("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\My Application.lnk")
Dim objSecId As Security.Principal.SecurityIdentifier
objSecId = Security.Principal.WindowsIdentity.GetCurrent.User
fInfo.GetAccessControl()
fSecurity.AddAccessRule(New Security.AccessControl.FileSystemAccessRule(objSecId, Security.AccessControl.FileSystemRights.Delete, Security.AccessControl.AccessControlType.Allow))
fInfo.SetAccessControl(fSecurity) 'UnauthorizedAccessException occurs here
fInfo.Delete()
Instead of above code using the following code -
Code:
File.Copy(SourcePath,DestinationPath,True)
File.Delete(SourcePath) 'UnauthorizedAccessException occurs here
Now the Error is "Access to the Path 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\My Application.lnk' is Denied" is Showing in Windows Vista.

The user is of Tye Administrator in Windows Vista. The user having Permission of Read and Execute from OS of the Specific folder / File mentioned. I want to provide the User add Delete permission for the file mentioned above through code.

Please help how to resolve this.

Thanks in advance.

Last edited by sanjoydas; 12-30-2008 at 12:16 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
file, permission, vista


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 8:58 PM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0


For advertising opportunities click here.