Extracting filename

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I am using openfiledialog to get user to select files and then I am
extracting the files using filenames(). How can I now separate the file path
from the actual filename?

Thanks

Regards
 
* "John said:
I am using openfiledialog to get user to select files and then I am
extracting the files using filenames(). How can I now separate the file path
from the actual filename?

Have a look at 'System.IO.Path.GetFileName'.
 
Hi John,

Or you could wonder about the usefulness of:
sFilePath.LastIndexOf ("\")

Regards,
Fergus
 
* "Fergus Cooney said:
Or you could wonder about the usefulness of:
sFilePath.LastIndexOf ("\")

Are you sure every platform uses "\" as path separator?
 
Hi Herfried,

There's only one that matters. ;-)

No, I'm just pointing out LastIndexOf(). I leave it to John to decide what
characters to check for.

Regards,
Fergus
 
* "Fergus Cooney said:
There's only one that matters. ;-)

On Windows systems. If the framework is ported to an other platform,
there may be other separators, for example "/".
 
Hi Herfried,

!! There's only one that matters. ;-)
^
^ This bit's the joke that says there's <only Windows>.

!! No,
^
^ This bit tells you that I'm aware of other systems.

!! I leave it to John to decide what characters to check for.
^
^ This bit says it's John's problem (or not - he knows where he's at).

Regards,
Fergus
 
Tom,
Actually Path.PathSeparator is a semi colon, as its the character that
separates a list of paths.

You are thinking Path.AltDirectorySeparatorChar &
Path.DirectorySeparatorChar, which separates a directory in a path.

And don't forget about Path.VolumeSeparatorChar which is the colon between
the drive letter & the rest of the path.

Plus there is Path.InvalidPathChars for characters we should not be using in
paths.

Hope this helps
Jay
 
Tom,
Actually Path.PathSeparator is a semi colon, as its the character that
separates a list of paths.

You are thinking Path.AltDirectorySeparatorChar &
Path.DirectorySeparatorChar, which separates a directory in a path.

And don't forget about Path.VolumeSeparatorChar which is the colon between
the drive letter & the rest of the path.

Plus there is Path.InvalidPathChars for characters we should not be using in
paths.

Hope this helps
Jay

Jay,

You are of course correct! I posted in haste, as usual :)
 
* "Fergus Cooney said:
!! There's only one that matters. ;-)
^
^ This bit's the joke that says there's <only Windows>.

!! No,
^
^ This bit tells you that I'm aware of other systems.

!! I leave it to John to decide what characters to check for.
^
^ This bit says it's John's problem (or not - he knows where he's at).

ACK. But the IO function will avoid all the problems and will be mach
more intuitive and better readable.
 
Back
Top