Author: utlandsfantomenno1 | Posted on: 9/24/2009 12:33:26 PM | Views : 306

 Hello!
 
I want to delete a file from a different process that the user is currently running. It's an asp.net site. Anyhow, I'll post some code to explain myself further:
Inherits System.Web.UI.Page Dim _cachedId As System.Security.Principal.WindowsIdentity ::::::::::::::::::::::: Public Shared Sub deleteMe(ByVal fileObject As Object) Dim token As IntPtr = IntPtr.Zero Dim impersonatedUser As System.Security.Principal.WindowsImpersonationContext = Nothing Try Dim id As System.Security.Principal.WindowsIdentity = _cachedId impersonatedUser = id.Impersonate() Catch Finally If Not impersonatedUser Is Nothing Then impersonatedUser.Undo() End If If token <> IntPtr.Zero Then CloseHandle(token) End If End Try Dim filePath ...

Go to the complete details ...