Mido
Mido

Reputation: 131

Check File Extension in Formview

I have a Formview that shows data from multitables. One of its rows contains path for a file saved in project folder.

I'd like to check this file extension and corresponding in its extension I will show an icon for every file extension.

For example, if the file is a .txt file I will show an icon for .txt files in formview

enter image description here

I'd like to replace [ ~/Files/Link.txt ] with an icon

Can this be done with an if Condition in the code-behind in the formview_bound event?

protected void FormView1_DataBound(object sender, EventArgs e)
{

}

Thanks.

Upvotes: 0

Views: 102

Answers (2)

Mido Ahmed
Mido Ahmed

Reputation: 26

Response.Write(Path.GetExtension(@"F:\Articles\ValidationControls\ValidationControls.zip"));

To get File Name,

Response.Write(Path.GetFileName(@"F:\Articles\ValidationControls\ValidationControls.zip"));

To get File name without extension,

Response.Write(Path.GetFileNameWithoutExtension(@"F:\Articles\ValidationControls\ValidationControls.zip"));

Upvotes: 0

Mido Ahmed
Mido Ahmed

Reputation: 26

string ext = System.IO.Path.GetExtension(this.File1.PostedFile.FileName);
if (ext==txt){
show icons with navigt
}

Upvotes: 1

Related Questions