Hi Tevin,
Use Process.Start to open the file from shared folder.
Refer below sample.
HTML
<asp:GridView ID="gvDetails" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Text" HeaderText="FileName" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkOpen" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Text")%>'
CommandArgument='<%#DataBinder.Eval(Container.DataItem, "Value")%>' OnClick="OnOpen"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Namespaces
C#
using System.Diagnostics;
using System.IO;
VB.Net
Imports System.Diagnostics
Imports System.IO
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string[] folderPaths = Directory.GetFiles(@"Shared Folder Path");
List<ListItem> files = new List<ListItem>();
foreach (string filePath in folderPaths)
{
files.Add(new ListItem(Path.GetFileName(filePath), filePath));
}
gvDetails.DataSource = files;
gvDetails.DataBind();
}
}
protected void OnOpen(object sender, EventArgs e)
{
string filePath = (sender as LinkButton).CommandArgument;
Process.Start(filePath);
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim folderPaths As String() = Directory.GetFiles("Shared Folder Path")
Dim files As List(Of ListItem) = New List(Of ListItem)()
For Each filePath As String In folderPaths
files.Add(New ListItem(Path.GetFileName(filePath), filePath))
Next
gvDetails.DataSource = files
gvDetails.DataBind()
End If
End Sub
Protected Sub OnOpen(ByVal sender As Object, ByVal e As EventArgs)
Dim filePath As String = (TryCast(sender, LinkButton)).CommandArgument
Process.Start(filePath)
End Sub
Screenshot