B
Brent Bigler
The computer: W2K server, domain controller, Microsoft.Net Framework 1.1
========================
The error message:
Access to the path "c:\fanmail\newfiles" is denied
....
Exception Details: System.UnauthorizedAccessException: Access to the path
"c:\fanmail\newfiles" is denied
*(see below for Stack Trace)
========================
Fixes tried (but didn't work):
1. Added ASPNET account to c:\fanmail\newfiles and granted full permission
to resource;
2. Added ASPNET to Administrator group;
3. Changed machine.config processModel username setting to "SYSTEM";
4. Changed machine.config processModel username setting to "{Domain}\ASPNET"
along with the password setting to the appropriate password;
5. Sacrificed three chickens and a goat (in theory).
=======================
Most of the articles I've read say it's simply a permissions problem, like
the error reports. But it doesn't seem that any kind of permission changing
on the resource works. Anything else I should try?
Thanks for any help!
--Brent
----------------------------------------------------------------------------
-
The code class giving me the problems (from clsFTP, downloaded from
someplace on the Web)
===================================
Public Sub DownloadFile(ByVal sFileName As String, _
ByVal sLocalFileName As String, _
ByVal bResume As Boolean)
Dim st As Stream
Dim output As FileStream
Dim cSocket As Socket
Dim offset, npos As Long
If (Not (m_bLoggedIn)) Then
Login()
End If
SetBinaryMode(True)
If (sLocalFileName.Equals("")) Then
sLocalFileName = sFileName
End If
If (Not (File.Exists(sLocalFileName))) Then
st = File.Create(sLocalFileName) '<----Error here, I presume
st.Close()
End If
output = New FileStream(sLocalFileName, FileMode.Open)
cSocket = CreateDataSocket()
offset = 0
If (bResume) Then
offset = output.Length
If (offset > 0) Then
SendCommand("REST " & offset)
If (m_iRetValue <> 350) Then
'throw new IOException(reply.Substring(4));
'Some servers may not support resuming.
offset = 0
End If
End If
If (offset > 0) Then
npos = output.Seek(offset, SeekOrigin.Begin)
End If
End If
SendCommand("RETR " & sFileName)
If (Not (m_iRetValue = 150 Or m_iRetValue = 125)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
Do While (True)
m_aBuffer.Clear(m_aBuffer, 0, m_aBuffer.Length)
m_iBytes = cSocket.Receive(m_aBuffer, m_aBuffer.Length, 0)
output.Write(m_aBuffer, 0, m_iBytes)
If (m_iBytes <= 0) Then
Exit Do
End If
Loop
output.Close()
If (cSocket.Connected) Then
cSocket.Close()
End If
ReadReply()
If (Not (m_iRetValue = 226 Or m_iRetValue = 250)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
End Sub
===========================
Stack Trace:
[UnauthorizedAccessException: Access to the path "c:\FanMail\NewFiles" is
denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean
bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize) +44
clsFTP.DownloadFile(String sFileName, String sLocalFileName, Boolean
bResume) +120
clsFTP.DownloadFile(String sFileName, String sLocalFileName) +13
ASP.test_aspx.Page_Load() in C:\ClientsWeb\test.aspx:20
System.Web.Util.ArglessEventHandlerDelegateProxy.Callback(Object sender,
EventArgs e) +10
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
========================
The error message:
Access to the path "c:\fanmail\newfiles" is denied
....
Exception Details: System.UnauthorizedAccessException: Access to the path
"c:\fanmail\newfiles" is denied
*(see below for Stack Trace)
========================
Fixes tried (but didn't work):
1. Added ASPNET account to c:\fanmail\newfiles and granted full permission
to resource;
2. Added ASPNET to Administrator group;
3. Changed machine.config processModel username setting to "SYSTEM";
4. Changed machine.config processModel username setting to "{Domain}\ASPNET"
along with the password setting to the appropriate password;
5. Sacrificed three chickens and a goat (in theory).
=======================
Most of the articles I've read say it's simply a permissions problem, like
the error reports. But it doesn't seem that any kind of permission changing
on the resource works. Anything else I should try?
Thanks for any help!
--Brent
----------------------------------------------------------------------------
-
The code class giving me the problems (from clsFTP, downloaded from
someplace on the Web)
===================================
Public Sub DownloadFile(ByVal sFileName As String, _
ByVal sLocalFileName As String, _
ByVal bResume As Boolean)
Dim st As Stream
Dim output As FileStream
Dim cSocket As Socket
Dim offset, npos As Long
If (Not (m_bLoggedIn)) Then
Login()
End If
SetBinaryMode(True)
If (sLocalFileName.Equals("")) Then
sLocalFileName = sFileName
End If
If (Not (File.Exists(sLocalFileName))) Then
st = File.Create(sLocalFileName) '<----Error here, I presume
st.Close()
End If
output = New FileStream(sLocalFileName, FileMode.Open)
cSocket = CreateDataSocket()
offset = 0
If (bResume) Then
offset = output.Length
If (offset > 0) Then
SendCommand("REST " & offset)
If (m_iRetValue <> 350) Then
'throw new IOException(reply.Substring(4));
'Some servers may not support resuming.
offset = 0
End If
End If
If (offset > 0) Then
npos = output.Seek(offset, SeekOrigin.Begin)
End If
End If
SendCommand("RETR " & sFileName)
If (Not (m_iRetValue = 150 Or m_iRetValue = 125)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
Do While (True)
m_aBuffer.Clear(m_aBuffer, 0, m_aBuffer.Length)
m_iBytes = cSocket.Receive(m_aBuffer, m_aBuffer.Length, 0)
output.Write(m_aBuffer, 0, m_iBytes)
If (m_iBytes <= 0) Then
Exit Do
End If
Loop
output.Close()
If (cSocket.Connected) Then
cSocket.Close()
End If
ReadReply()
If (Not (m_iRetValue = 226 Or m_iRetValue = 250)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
End Sub
===========================
Stack Trace:
[UnauthorizedAccessException: Access to the path "c:\FanMail\NewFiles" is
denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean
bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize) +44
clsFTP.DownloadFile(String sFileName, String sLocalFileName, Boolean
bResume) +120
clsFTP.DownloadFile(String sFileName, String sLocalFileName) +13
ASP.test_aspx.Page_Load() in C:\ClientsWeb\test.aspx:20
System.Web.Util.ArglessEventHandlerDelegateProxy.Callback(Object sender,
EventArgs e) +10
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731