Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

file properties

  Asked By: Aysel    Date: Dec 02    Category: Asp.net    Views: 785
  

I like to use Response.write to write the name of a file BUT without
the extension (.txt, .html etc). Something similar to this:
Response.Write("Name : " & objFile.Name & ""). Can anyone help?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Geneva Morris     Answered On: Dec 02

Maybe this sample help  you:


// create a reference to the current directory
DirectoryInfo di = new DirectoryInfo(Environment.CurrentDirectory);
// create an array representing the files in the current directory
FileInfo[] fi = di.GetFiles();
Console.WriteLine("The following files exist in the current directory:");
// print out the names of those files
foreach (FileInfo fiTemp in fi)
// get the name od the file  througgh the fileInfo class and trim it with the exstension
Console.WriteLine(fiTemp.Name.TrimEnd(fiTemp.Extension.ToCharArray()));

 
Didn't find what you were looking for? Find more on file properties Or get search suggestion and latest updates.




Tagged: