Click here to Skip to main content
15,902,745 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
pr.StartInfo.Arguments = i.SubItems(3).Text.Remove(i.SubItems(3).Text.LastIndexOf("\") + 1, _
                                                (i.SubItems(3).Text.Length - i.SubItems(3).Text.LastIndexOf("\") - 1))





The subitems(3).text is for exemple : C:\Program Files (x86)\Internet Download Manager\IDMAN.exe
Posted

1 solution

Removes the final part of the string, from the last occurring "\" character (excluded).
You may re-write it as
VB
s.Remove(s.LastIndexOf("\") + 1, s.Lenght - s.LastIndexOf("\") - 1)


where s.LastIndexOf("\") is the index of the last occurring "\" character, hence
s.Lenght -s.LastIndexOf("\")-1 is the number of characters following the last "\".

See String.Remove Method (Int32, Int32)[^].
 
Share this answer
 
Comments
Haykerman 23-Jun-13 9:05am    
Thanks can you explain me : what is +1 and -1 ?
CPallini 23-Jun-13 12:54pm    
You need +1 because you want to remove the part of the string succeeding the last "\" occurrence. Then you may find the same +1, negated, in the formula that computes the length of such part of the string.
Haykerman 23-Jun-13 14:57pm    
Thanks!
CPallini 23-Jun-13 15:09pm    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900