-3

Im trying to get file name without its extension, i have the following code that let me take the file name with extension which is

var docName = new DirectoryInfo("C:\\files\\").GetFiles("*.docx");

with that code im taking all of the file names then use them on

 for(int a = 0; a < docLength; a++)
        {
           Consol.WriteLine("Your File Name : {0}", docName[a] ) // this part is just ex.
        }

when i execute the program it will list the file names like

Test.txt
test.docx

and etc.

how can i get the document names without their extensions like

test
Enes a.
  • 1
  • 2

1 Answers1

0

You might want to use this

https://docs.microsoft.com/en-us/dotnet/api/system.io.path.getfilenamewithoutextension?view=netframework-4.8

I think it does exactly what you want to do