|
-
Jan 7th, 2020, 11:48 AM
#1
Re: How to get just the pathway from a pathway and a filename? :)
I've always just used InStrRev(s, "\") for years, and I've never had a problem with it. However, I'll admit that I'm always very careful to only use it when I know I've got a full specification string (path and filename). I've sometimes wondered what would happen if I had a full-spec with a file in the root, maybe something like "C:MyFile.txt", but I just never do that. And, that would be better specified as "C:\MyFile.txt", in which case the InStrRev(s, "\") would work.
If you want something that will work even when the filename may not be part of the string, then you've got other problems: 1) is terminating back-slash present?, 2) is it a filename without an extension?, 3) would it be possible to check to see if the path exists as part of the function?, 4) is speed important?
Last edited by Elroy; Jan 7th, 2020 at 11:51 AM.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|