Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENIED)

Mnemonic

Member
Joined
May 24, 2007
Messages
9
Programming Experience
1-3
Hey guys, im writing an app that finds and replaces strings in a text file and then writes it as a new file in a seperate directory. When i deploy it to a server, ive givin that directory all the permissions it needs (Even everyone has full access) and i keep getting Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENIED). The process acctually creates a text file, then opens it up for appending and appends the new text in. The file gets created file, but at the appending point is where this exception is thrown.

Here is my code for that part:

Dim output As String
output = sb.ToString



Dim strOutputFile = "D:\Logs\N\" & strfile

Dim objFileSystem = CreateObject("Scripting.fileSystemObject")
Dim objOutputFile = objFileSystem.CreateTextFile(strOutputFile, True)


objOutputFile.Close()

objFileSystem = Nothing
objOutputFile = Nothing



Dim objwriter As StreamWriter
objwriter = File.AppendText("D:\Logs\N\" & strfile)
Const OPEN_FILE_FOR_APPENDING = 8

' generate a filename base on the script name
Dim strOutputFile2 = "D:\Logs\N\" & strfile

objFileSystem = CreateObject("Scripting.fileSystemObject")
objOutputFile = objFileSystem.OpenTextFile(strOutputFile2, _
OPEN_FILE_FOR_APPENDING)
objwriter.Flush()

objOutputFile.WriteLine(sb.ToString)
objOutputFile.Close()

objFileSystem = Nothing
reader.Close()
objwriter.Close()
 
.Net Framework does not allow applications to run from untrusted locations like file shares. You have to use the .Net Framework Configuration tool (Control Panel > Administrative) to trust either the location or the assembly or a strong name. An alternative to the configuration dialog is to use the Caspol.exe commandline tool.
 
Back
Top