Reputation: 81
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)
Upvotes: 2
Views: 82
Reputation: 137188
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);
Upvotes: 3
Reputation: 40160
You would use Path.GetFileName()
to get just the filename.
string fileName = Path.GetFileName(sfd.FileName);
Upvotes: 4