Click here to Skip to main content
15,896,287 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm displaying a text file on a webpage but do not want to show the .txt extension. How do I hide the extension?

What I have tried:

This is a sample of my code: I've tried to format "SiteFileName" to exclude the extension but I have not been successful.
<div class="col-xs-12">
                    @for (int c = 1; c <= ViewBag.NewFiles.Count; c++)
                    {
                        @*change Admits to File*@
                        iFTDTL.Areas.admits.Models.File a = ViewBag.NewFiles[c - 1];
                        <div class="col-xs-2">@c</div>
                        <div class="col-xs-5">@Html.ActionLink(a.SiteFilename, "DownloadFile", new { a.Id })</div>
                        <div class="col-xs-2">@a.RecordCount</div>
                        <div class="col-xs-3">@a.CreateDate.ToString("yyyy-MMM-dd")</div>                     
                    }
                </div>
Posted
Updated 31-May-18 7:04am

1 solution

@Html.ActionLink(System.IO.Path.GetFileNameWithoutExtension(a.SiteFilename), "DownloadFile", new { a.Id })

Path.GetFileNameWithoutExtension Method (System.IO) | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900