Check given path is of directory or direct file path

Dear Forum members

I have an excel file and in that file in a column i have some directory path and in some cell i have direct path of file(including file name and extension), so how i can check the given path is of directory or direct file path.

Thankx in advance

@Yankit_singh What are extensions of files for the full file path?

Thankx for response

Extensions of full file path are .txt, .pdf, .doc, .xlsx

@Yankit_singh
Use GetExtension method

  1. Directory path will give you empty:
    Path.GetExtension(“C:\Users\PRAVIN\Documents”)

  2. Full path will give you extention
    Path.GetExtension(“C:\Users\PRAVIN\Documents\Book1234.xlsx”)

Then use if condition with if value is empty then it’s directory path or else full file path…

Thankx buddy

It’s working fine.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.