2

I'm saving something from winform to a file, with SaveFileDialog (svf), and I would like to use the name of the file, after saving, how can I do it?

sfd.FileName; 

It's not the right way, because it has got the path too... (for example:c:/asd/asd/asd.doc)

0

2 Answers 2

4

You would use Path.GetFileName() to get just the filename.

string fileName = Path.GetFileName(sfd.FileName); 
Sign up to request clarification or add additional context in comments.

Comments

3

You need to use the various Path methods to split the path into the various components you need.

In this case it's Path.GetFileName

string filename = Path.GetFileName(sfd.FileName); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.