0

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.

2
Contributors
4
Replies
5
Views
11 Years
Discussion Span
Last Post by toadzky
0

I'm using VC++, Windows Forms App. I think its just C++ .NET.

0

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(). :)

0

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.

TIA.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.