Answers for "c# extension fileinfo"

C#
5

c# get file extension

string myFilePath = @"C:\MyFile.txt";
string ext = Path.GetExtension(myFilePath);
// ext would be ".txt"
Posted by: Guest on August-11-2020
-1

c# fileinfo filename without extension

DirectoryInfo dir = new DirectoryInfo(path);
FileInfo[] files = dir.GetFiles("*.txt");

foreach (FileInfo file in files)
{
    string noExtension = Path.GetFileNameWithoutExtension(file.Name);
}
Posted by: Guest on March-04-2021

C# Answers by Framework

Browse Popular Code Answers by Language