Can't Use Path in ASP MVC Action
Posted
by
user1477388
on Stack Overflow
See other posts from Stack Overflow
or by user1477388
Published on 2012-10-17T16:52:59Z
Indexed on
2012/10/17
17:01 UTC
Read the original article
Hit count: 307
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
© Stack Overflow or respective owner