Live Chat Icon For mobile
Live Chat Icon

How to get the File information using ASP.NET

Platform: ASP.NET| Category: Files

Use the namepsace System.IO

VB.NET


Dim fPath As String = Server.MapPath('orders.xml')
Dim fInfo As New FileInfo(fPath)
Dim strFileInfo As String
If fInfo.Exists Then
   	strFileInfo = 'Name: ' + fInfo.Name + '<br />'
	strFileInfo += 'Location: ' + fInfo.FullName + '<br />'
	strFileInfo += 'Created on: ' + fInfo.CreationTime + '<br />'
	strFileInfo += 'Extension: ' + fInfo.Extension
Else
	strFileInfo = 'The  file <b>' + fPath + '</b> was not found.'
End If
Response.Write(strFileInfo)

C#


string fPath = Server.MapPath('orders.xml');
FileInfo fInfo = new FileInfo(fPath);	
string strFileInfo ;
if(fInfo.Exists) 
{
	strFileInfo = 'Name: ' + fInfo.Name + '<br />'; 
	strFileInfo += 'Location: ' + fInfo.FullName + '<br />'; 
	strFileInfo += 'Created on: ' + fInfo.CreationTime + '<br />'; 
 	strFileInfo += 'Extension: ' + fInfo.Extension;
} 
else 
{
	strFileInfo = 'The  file <b>' +  fPath + '</b> was not found.';
}	
Response.Write (strFileInfo);

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.