Ho creato una form tipo "multipart/form-data" e con tag input per inviare un file sul server in una directory.
Il codice è il seguente:
Private Sub btnInvio_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInvio.ServerClick
Dim percorso As String
If Not IsNothing(file.PostedFile) Then
percorso = "//" + Request.UserHostName + Request.ApplicationPath + "/xls/"
Dim filepath As String = Path.Combine(percorso, Path.GetFileName(file.Value))
Try
file.PostedFile.SaveAs(filepath)
Span1.InnerHtml = "File uploaded successfully to " & filepath & " on the web server"
Catch Exc As Exception
Span1.InnerHtml = "Error saving file " & filepath & "
" & Exc.ToString()
End Try
End If
End Sub
purtroppo però scatta sempre l'eccezione.
Mi dice System.UnauthorizedAccessException.
COme mai mi dice che l'accesso alla directory è negato? Da IIS ho impostato quella directory con tutti i privilegi (anche di scrittura).
Mi potete aiutare?

Rispondi quotando