ASP.Net/File Directory/Directory — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 14:51, 26 мая 2010
Get all exe files (C#)
<source lang="csharp">
<%@ Page Language="C#" %> <%@ import Namespace="System.IO" %> <script runat="server">
private void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { String[] FileCollection; FileInfo FileInfo; int i; FileCollection = Directory.GetFiles(@"C:\WINNT","*.exe"); for (i=0; i < FileCollection.Length; i++) { FileInfo = new FileInfo(FileCollection[i]); FileListBox.Items.Add(new ListItem(FileInfo.Name.ToString())); } } }
</script> <html>
<head> </head> <body> <form runat="server"> EXE Files in Folder C:\WINNT: <asp:ListBox id="FileListBox" Runat="Server" /> </form> </body>
</html>
</source>
Get all exe files (VB)
<source lang="csharp">
<%@ Page Language="VB" %> <%@ import Namespace="System.IO" %> <script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs) If Not IsPostBack Then Dim FileCollection As String() Dim myFileInfo As FileInfo Dim i as integer FileCollection = Directory.GetFiles("C:\WINNT","*.exe") For i = 0 To FileCollection.Length - 1 myFileInfo = New FileInfo(FileCollection(i)) FileListBox.Items.Add(new ListItem(myFileInfo.Name.ToString())) Next End If End Sub
</script> <html>
<head> </head> <body>
<form runat="server">
EXE Files in Folder C:\WINNT: <asp:ListBox id="FileListBox" Runat="Server" />
</form>
</body>
</html>
</source>