ASP.NET MVC 응용 프로그램에서이보기가 있습니다.루프 내부에서 foreach의 LINQ 부분을 활용할 수 있습니까?
<%
var path = Path.Combine(HttpRuntime.AppDomainAppPath, "uploads");
foreach (var file in Directory.GetFiles(path).OrderBy(f => new FileInfo(f).Length))
{
var item = new FileInfo(file);
%>
<tr>
<td></td>
<td>
<%=Html.Encode(Path.GetFileName(item.Name))%>
</td>
<td>
<%=Html.Encode(Functions.FormatBytes(item.Length))%>
</td>
<td>
<%=Html.FileLink(item.Name)%>
</td>
</tr>
<% } %>
루프 내에서
f
변수에 액세스 할 수 있습니까? 아니면 두 가지 인스턴스에 치수를 지정할 필요가없는 다른 방법이 있습니다.
FileInfo(file)
의?
고마워!
ack, 가장 간단한 해결책은 항상 나를 피합니다. 고마워요 :) – Anders