quote:
Originally posted by Jesus
...which essentially does the same as
js code:
Messenger.MyPersonalMessage = fileName.Name.substring(0, fileName.Name.lastIndexOf("."))
back on windows, so it's tested this time
Sorry but that is not completely correct.
A file does not
have to have an extension (.xxx).
lastIndexOf() will return -1 if there is no period in the string.
This leaves us with substring(0, -1), which will return "".
If I should further explain why I wrote the code that way, I will do so...
The reason why I used a new function, is to seperate your custom code from the original code as much as possible. It is easier for you to make changes that way.
You can of course use fileName.Name instead, because it does not really matter which one you use in this case.
However, by using fileName.Path, you can use both the full path (NewFileName) and just the name (tempFileName) in your own code without making any changes if you somehow want to do something with both.
I like clean and reliable code.
To make it extra clean, you could even put your own code in new files if there is a lot of code.
Please correct me if I am mistaken about anything.