Can't Use Path in ASP MVC Action
- by user1477388
I am trying to use Path() but it has a blue line under it and says, "local variable (path) cannot be referred to until it is declared." How can I use Path()?
Imports System.Globalization
Imports System.IO
Public Class MessageController
Inherits System.Web.Mvc.Controller
<EmployeeAuthorize()>
<HttpPost()>
Function SendReply(ByVal id As Integer, ByVal message As String, ByVal files As IEnumerable(Of HttpPostedFileBase)) As JsonResult
' upload files
For Each i In files
If (i.ContentLength > 0) Then
Dim fileName = path.GetFileName(i.FileName)
Dim path = path.Combine(Server.MapPath("~/App_Data/uploads"), fileName)
i.SaveAs(path)
End If
Next
End Function
End Class