キープしました。負でなく、コレクションのサイズより小さくなければなりません。パラメータ名:indexC#のデータグリッドインデックスが範囲外のこの行のエラーを取得
私のdatagridからvar/string(パス+ファイル名を保持)にセルを保存しようとしていますので、ftpで削除できます。
private void button2_Click(object sender, RoutedEventArgs e)
{
var imagePath = dataGrid1.SelectedItems[5].ToString();
Student selected = dataGrid1.SelectedItem as Student;
if (selected == null)
MessageBox.Show("You must select a student");
else
{
if (MessageBoxResult.Yes == MessageBox.Show("Are you sure", "delete student",
MessageBoxButton.YesNo, MessageBoxImage.Warning))
{
FTPdelete(imagePath, "Administrator", "commando");
Class1.DeleteStudent(selected);
Window_Loaded(null, null);
}
}
}
private void FTPdelete(String imagePath, String inUsername, String inPassword)
{
var req = (FtpWebRequest)WebRequest.Create(imagePath);
req.Proxy = null;
req.Credentials = new NetworkCredential(inUsername, inPassword);
req.Method = WebRequestMethods.Ftp.DeleteFile;
req.GetResponse().Close();
}
}
}
はあなたのように見える**選択したアイテムの第六は、**コラムをお勧めします:学生のImagePathを持っている場合
、あなたは少しだけ持っているが、順序再だろうか? –