i have following text file called urlmap.txt in app_data
showproduct.aspx?id=1143, laptops/1143/laptops-for-beginner-experienced-engineers showproduct.aspx?id=1142, desktops/1142/dynamic-difference-desktops showproduct.aspx?id=1141, keyboards/1141/bluetooth-ready-keyboards showproduct.aspx?id=1140, mouse/1140/microsoft-2key-mouse-with-pad showproduct.aspx?id=1139, mouse/1139/logitech-3key-mouse-auto-shutoff , 2000 such entries.... i want pass in string "showproduct.aspx?id=1140" , search , retrieve text in front of i.e. "mouse/1140/microsoft-2key-mouse-with-pad"
if string not found, retrieves nothing.
each string in urlmap.txt unique, there no chance of duplication
how can this?
this have far unable determine how retreive text in front of it
string line; stringbuilder sb = new stringbuilder(); using (system.io.streamreader file = new system.io.streamreader("app_data\urlmap.txt")) { while ((line = file.readline()) != null) { if (line.contains(mysearchstring)) { } } } since text file contains 2000+lines, need optimized way of retrieving record.
just use split:
if (line.contains(mysearchstring)) { var text = line.split(",")[1]; /*do else text*/ }
Comments
Post a Comment