I am having trouble uploading any file to the path in the error message below. Does anyone have any idea what the problem is. I did some research on this and most sites say that the permissions need Read/Write access for the asp.net user. I tried this and I still receiver the error. Here is the error:
For example Error saving file education_calendar.pdf System.IO.DirectoryNotFoundException: Could not find a part of the path "d:\inetpub\aopha\Uploads\". at System.IO.__Error.
Here is my code for the click event. I am not sure what is happening here:
Private Sub cmdUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpload.Click
If IsPostBack Then
Dim MyFileColl As HttpFileCollection = Request.Files
Dim MyPostedMember As HttpPostedFile = MyFileColl.Get("File1")
Dim MyFileName As String = MyPostedMember.FileName
If Not MyPostedMember Is Nothing Then
Try
Dim intFileNameLength As Integer = InStr(1, StrReverse(MyFileName), "\")
Dim strFileNameOnly As String = Mid(MyFileName, (Len(MyFileName) - intFileNameLength) + 2)
Dim RootPath As String = Server.MapPath("/")
'APPEND THE APPROPRIATE FOLDER
Dim tmpFolder As String = FileLoc.SelectedValue 'HttpContext.Current.Request.Form("FileLoc")
Dim WebFilePath As String = Server.MapPath(tmpFolder & strFileNameOnly) 'HttpContext.Current.Request.MapPath(tmpFolder & strFileNameOnly)
MyPostedMember.SaveAs(WebFilePath.ToString)
Dim LinkPath As String = WebFilePath.Replace(RootPath, "")
LinkPath = "/" & LinkPath.Replace("\", "/")
lblMessage.Text = "Successfully saved file: <a href=""" & LinkPath & """ target=""_blank"">" _
& tmpFolder & strFileNameOnly & "</a>"
'return the file to the opening window.
Dim strScript As String = "<script>window.opener.document.forms(0)." + control.Value + ".value = '"
If Request.QueryString("retPath") = "link" Then
strScript += LinkPath
Else
strScript += strFileNameOnly
End If
strScript += "';self.close()"
strScript += "</" + "script>"
RegisterClientScriptBlock("anything", strScript)
Catch exc As Exception
lblMessage.Text = "Error saving file <b>" _
& File1.Value & "</b><br>" & exc.ToString()
End Try
End If
End If
End Sub