I need to compare combobox items (text) with the filename.
I tried doing something like this:
for(int x =0; x>comboBox1.Items.Count; x++)
{
if (comboBox1.Items[x].ToString() == filename)
// something
}
But this is not working.
Can I do something like this:
If comboBox1 (all items) = (logpath + *.log) ???
string logpath is the path for the log file.

1 answers
The problem is that you're using 'greater than' when you should be using 'less than':
You can also use:
However, because of the complexities of object equality and the way strings are handled internally by .NET, I can't guarantee that this will always work properly.
I didn't really follow the second part of your question but, if you're asking whether 'filename' can contain wildcards in the above code, then the answer is 'no'. You'd probably need to use regular expressions instead.
answered one year ago by:
17279
412
I'm trying to fetch the filename like this: string filename = Form1.Paths.logpath + comboBox1.Text + ".tmp"; But this is not working. Why so??
17279
Three possibilities occur to me : (1) Form1.Paths.logpath doesn't contain a path with a closing backslash, (2) there isn't actually a file showing in the textbox part of the combobox or (3) there is a file showing in the combobox but it already includes an extension.
412
I've chekd (1)the logpath's value and it is "V:\\", (2) Not able to understand "file showing in the textbox part of the combobox". combobox is list of names only (GS Virdi).(3) no extension in the list of names in combobox. I've just tried to create a temp file with the name of the logged in user, and I'm trying to fetch the name of the user so that it can be displayed in the popup message to another user if they try to login.
412
Solution found Thx a lot for ur help vulpes. :)