ambreesh
September 8th, 2005, 03:52 PM
I am trying to upload a file using the following program
If Not File1.PostedFile Is Nothing And File1.PostedFile.ContentLength > 0 Then
Dim fn As String = System.IO.Path.GetFileName(File1.PostedFile.FileName)
' Dim SaveLocation As String = Server.MapPath("Data") & "\" & fn
Dim savelocation = "C:\upload\Data"
Try
File1.PostedFile.SaveAs(SaveLocation)
Response.Write("The file has been uploaded.")
Catch Exc As Exception
Response.Write("Error: " & Exc.Message)
End Try
Else
Response.Write("Please select a file to upload.")
I am not one of those people who would post random code on the website and ask people to debug. I have tested this code and it works fine for webshares, once I insert an absolute path in the savelocation string, I get the following error message.
Error: Access to the path "C:\upload\Data" is denied.
where "C:\uploade\Data is my absolute path. I have given all possible access to the folder "Data" including anonymous + ASPNET access.
Does some know what may be going wrong?
If Not File1.PostedFile Is Nothing And File1.PostedFile.ContentLength > 0 Then
Dim fn As String = System.IO.Path.GetFileName(File1.PostedFile.FileName)
' Dim SaveLocation As String = Server.MapPath("Data") & "\" & fn
Dim savelocation = "C:\upload\Data"
Try
File1.PostedFile.SaveAs(SaveLocation)
Response.Write("The file has been uploaded.")
Catch Exc As Exception
Response.Write("Error: " & Exc.Message)
End Try
Else
Response.Write("Please select a file to upload.")
I am not one of those people who would post random code on the website and ask people to debug. I have tested this code and it works fine for webshares, once I insert an absolute path in the savelocation string, I get the following error message.
Error: Access to the path "C:\upload\Data" is denied.
where "C:\uploade\Data is my absolute path. I have given all possible access to the folder "Data" including anonymous + ASPNET access.
Does some know what may be going wrong?