我有以下結構 for
for (int i = 0; i < lstArquivosRetorno.Items.Count; i )
{
lstArquivosRetorno.SetSelected(i, true);
string nomeArquivo = string.Format(
"{0}{1}",
Funcoes.IncludeBackSlash(edtPathArquivo.Text),
lstArquivosRetorno.SelectedItem.ToString());
_relacaoArquivos.Add(nomeArquivo);
}
我正在做的是以下內容:我有一個List<string> _relacaoArquivos并使用該結構將檔案名添加到該串列中,但是,如果我選擇了多個檔案,它只會存盤并添加第一個檔案。
如何通過我的for結構來存盤所有檔案的名稱并將其添加到串列中?
uj5u.com熱心網友回復:
lstArquivosRetorno看起來像一個選擇串列或類似的。創建nomeArquivo字串時,將SelectedItem使用 來創建字串。這就是為什么您只將一項添加到_relacaoArquivos串列中的原因。
lstArquivosRetorno.SelectedItem 應該 lstArquivosRetorno.Items[i]
string nomeArquivo = string.Format(
"{0}{1}",
Funcoes.IncludeBackSlash(edtPathArquivo.Text),
lstArquivosRetorno.Items[i]); // no need to call ToString()
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/365810.html
上一篇:Automapper和多維串列
下一篇:EFCore運行單一遷移
