I am writing a program to batch rename files. I am trying to take the file name (which include folders) and remove everything before the last slash.
The problem is that LastIndexOf("\\") always returns -1, even if the string contains a "\".
And the Remove(0, index) doesn't ever remove any characters from the string.
If I were using std::strings, I would just use the findLastNotOf() and erase() functions.
TIA.
Last edited by toadzky; Mar 28th, 2007 at 4:43 am.
If you're using VC++ then using std::string is not problem !
C++ .NET -> I donno.
Reason why I said sounds like JavaScript is coz I googled the functions you'd posted and all links pointed to some JavaScript or the other.
Coming back to the problem, I'm sorry but without knowing teh function I can't comment. If you've spent enough time on this I suggest just implement your own find_first_of() and erase().
Well, I fixed the LastIndexOf part. I finally realized that I was doing a search from back to front and the index I told it to start from was 0. So it never looked at the string.
That's working just fine, but the remove function still won't remove anything from the string.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.