Finding File Paths from string
-
hi guys ! need some help i have to find out the file paths between string which has to be taken from User from a richtextbox the problem is there is no specified location on which the user will type the path .. it can be any where in the string for eg. user entered data something like this :
If the above link is not visible then run the application “C:\Program Files\CasinoOnNet\Unwise.exe” and follow the instructions to uninstall the Casino on Net.
i have to find “C:\Program Files\CasinoOnNet\Unwise.exe” in this string. these paths can be more than one and it is not necessary that they are in Quotes.. is there any way to find such paths .. any idea abhinav
-
hi guys ! need some help i have to find out the file paths between string which has to be taken from User from a richtextbox the problem is there is no specified location on which the user will type the path .. it can be any where in the string for eg. user entered data something like this :
If the above link is not visible then run the application “C:\Program Files\CasinoOnNet\Unwise.exe” and follow the instructions to uninstall the Casino on Net.
i have to find “C:\Program Files\CasinoOnNet\Unwise.exe” in this string. these paths can be more than one and it is not necessary that they are in Quotes.. is there any way to find such paths .. any idea abhinav
A simplistic approach that (may) provide reasonably good results is:
search for the first occurence of a backslash character (\);
if (found) {
rewind to first previous space;
extract substring to next space (or end of string);
in source string, replace substring with empty string;
return substring;
}
return "";PS: This is highly NOT a perfect solution. In particular, it won't properly handle paths containing embedded spaces. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com
-
hi guys ! need some help i have to find out the file paths between string which has to be taken from User from a richtextbox the problem is there is no specified location on which the user will type the path .. it can be any where in the string for eg. user entered data something like this :
If the above link is not visible then run the application “C:\Program Files\CasinoOnNet\Unwise.exe” and follow the instructions to uninstall the Casino on Net.
i have to find “C:\Program Files\CasinoOnNet\Unwise.exe” in this string. these paths can be more than one and it is not necessary that they are in Quotes.. is there any way to find such paths .. any idea abhinav
Use Regular Expressions: using System.Text.RegularExpressions; ... //Find all paths in the string MatchCollection matches = Regex.Matches(richTextBox1.Text, "\\b[a-z]\\:(\\\\[^\\n\\r\\f\\t\\\\/<>|\":*?]+)*\\b", RegexOptions.IgnoreCase); foreach (Match m in matches) { //do whatever you need to for each path found in the string. The entire path can be found using m.Value //you can also find the index and length of the path in the string by accessing other fields of m. } Hope this helps, DigitalKing
-
hi guys ! need some help i have to find out the file paths between string which has to be taken from User from a richtextbox the problem is there is no specified location on which the user will type the path .. it can be any where in the string for eg. user entered data something like this :
If the above link is not visible then run the application “C:\Program Files\CasinoOnNet\Unwise.exe” and follow the instructions to uninstall the Casino on Net.
i have to find “C:\Program Files\CasinoOnNet\Unwise.exe” in this string. these paths can be more than one and it is not necessary that they are in Quotes.. is there any way to find such paths .. any idea abhinav