>>>Hi All,
>>>
>>>I have a method that returns a string if there is no file in a directory. I have stepped through this and watched this line get set to an empty string but when it comes back to the calling line of code, it is null. I am missing something and wonder if it is the way I did the while statement. Any ideas appreciated.
>>>Thanks for the help
>>>Tim
>>>
>>>When the return from PopQueue is set to "" then in my while statement the value of fileName is null. Why would this be?
>>>
>>>while ((fileName = this.PopQueue(path, filter)) != "" && llSuccess)
>>>{
>>> // Do all my stuff here, process each file returned until no more files are returned.
>>>}
>>>
>>This line while ((fileName = this.PopQueue(path, filter)) != "" && llSuccess)
>>is a bit strange.
>>
>>I would try to create a separate variable
>>
>>string fileName;
>>
>>fileName = this.PopQueue(path, filter);
>>
>>while (fileName !="" && llSuccess)
>>(
>> fileName = ..;
>> do stuff
>>}
>>
>>>
>The problem with this Naomi is the fileName variable would never change since it occurs prior to the while loop. I need to reset fileName as what drives the loop. I agree it is a bit funky to read but why does fileName get set to "" and then be null when it gets back to here? I don't understand that.
>Tim
Look closer to my suggestion. You need to re-assign this filename variable again inside the loop. I think it's clearer than assignment and comparision as you're currently trying. At least for me it's simpler to understand and maintain.
If it's not broken, fix it until it is.
My Blog