Reputation: 1614
Typical problem, but I've done everything I can possibly think of to get this to work. I set the NETWORK SERVICE and ASPNET accounts to FULL CONTROL on my PC. I'm using the built-in Cassini web server to test my application, with no luck. I even tried to make a folder outside of the APP_DATA folder, and is still says Access is Denied.
Anyone have any ideas?
CODE EXAMPLE:
Dim uploadedFile As HttpPostedFile = Request.Files(0)
Dim len As Integer = uploadedFile.ContentLength
Dim fn As String = Path.GetFileName(uploadedFile.FileName)
Dim SaveLocation As String = Server.MapPath("~/Help")
Dim MyStream As Stream = uploadedFile.InputStream
Dim input(len) As Byte
MyStream = uploadedFile.InputStream
MyStream.Read(input, 0, len)
Try
Dim newFile As FileStream = New FileStream(SaveLocation, FileMode.Create)
newFile.Write(input, 0, input.Length)
newFile.Close()
'Dim writer As Stream = New FileStream(SaveLocation, FileMode.Create)
'writer.Read()
'writer.Close()
'uploadedFile.SaveAs(SaveLocation)
Catch ex As Exception
End Try
Upvotes: 0
Views: 2864
Reputation: 1614
Alright, I figured it out. I needed to have the filename in the SaveLocation. Completely missed that.
Upvotes: 2
Reputation: 5381
If you're using IIS, find out what system (or user) account for the application pool for the site you are having issues with. Check to make sure that that user has permissions to the folder in question.
If you're in Visual Studio 2005+, it is rolling up a new ASP.NET Development Server. This runs as your currently logged-in account. Are you a local admin on this machine?
Upvotes: 0
Reputation: 15754
Which version of IIS are you using?
On IIS 6 and higher it is NETWORK SERVICE.
On IIS 5 and below it is the ASPNET user account that needs the required access.
Upvotes: 0