Ø
Øyvind Isaksen
Hi,
I have made a code that list all files in a directory on the server.
It works fine, but I need to modify the filename (remove the 7 first char in
the name) that is displayed in the datagrid.
Example:
The file "123456_myfile.jpg" shoult be displayed like this: "myfile.jpg"
---------------------------
This is my code so far:
---------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim dirInfo As New
DirectoryInfo(Server.MapPath("/uploads/isaksenmedia/"))
Me.dtgFilelist.DataSource = dirInfo.GetFiles("*.*")
Me.dtgFilelist.DataBind()
End Sub
<aspataGrid id="dtgFilelist" runat="server" autogeneratecolumns="False">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Name"
DataTextField="Name" HeaderText="Filename" />
<asp:BoundColumn DataField="LastWriteTime" HeaderText="Modyfied"
DataFormatString="{0:d}" />
<asp:BoundColumn DataField="Length" HeaderText="Size"
DataFormatString="{0:#,### bytes}" />
</Columns>
</aspataGrid>
Thanks!!!!!!
I have made a code that list all files in a directory on the server.
It works fine, but I need to modify the filename (remove the 7 first char in
the name) that is displayed in the datagrid.
Example:
The file "123456_myfile.jpg" shoult be displayed like this: "myfile.jpg"
---------------------------
This is my code so far:
---------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim dirInfo As New
DirectoryInfo(Server.MapPath("/uploads/isaksenmedia/"))
Me.dtgFilelist.DataSource = dirInfo.GetFiles("*.*")
Me.dtgFilelist.DataBind()
End Sub
<aspataGrid id="dtgFilelist" runat="server" autogeneratecolumns="False">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Name"
DataTextField="Name" HeaderText="Filename" />
<asp:BoundColumn DataField="LastWriteTime" HeaderText="Modyfied"
DataFormatString="{0:d}" />
<asp:BoundColumn DataField="Length" HeaderText="Size"
DataFormatString="{0:#,### bytes}" />
</Columns>
</aspataGrid>
Thanks!!!!!!