aewarnick Posted February 20, 2003 Posted February 20, 2003 int start=FileArr.LastIndexOf('.'); file=FileArr.Remove(start, FileArr.Length); In bold is the problem. I cannot figure out a way for Remove to just go to the end of the sting, without going through alot more trouble. There should be some kind of method to do it but what is it. .Length returns the length of the whole string and an error is produced. Quote C#
Heiko Posted February 20, 2003 Posted February 20, 2003 Remove's second parameter is the length of the substring to remove? Then that would be: file=FileArr.Remove(FileArr.LastIndexOf('.'), FileArr.Length - FileArr.LastIndexOf('.')+1); (I suppose) Quote .nerd
aewarnick Posted February 20, 2003 Author Posted February 20, 2003 int start=FileArr.LastIndexOf('.'); file=FileArr.Remove(start, FileArr.Length - start); That works perfectly. Quote C#
Heiko Posted February 20, 2003 Posted February 20, 2003 Ups. What about the last "." ? Thats why I suggested to remove one more character. Well nevermind :-) Quote .nerd
aewarnick Posted February 20, 2003 Author Posted February 20, 2003 It is not a sentence. It is a file. I am removing the extention. Quote C#
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.