Hi All,

How can I get sample.xls from C:\users\sample\desktop\sample.xls to string?

Thank you.

I answered my own question :D

string path = Path.GetFileNameWithoutExtension("C:\users\sample\desktop\sample.xls");

Answer: sample

I answered my own question :D

Technically that's not the correct answer to your question, though it's close. Your question was how to extract "sample.xls", not "sample". In that case you need Path.GetFileName(). ;)

Thank you! ^_^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.