0

こんにちは、WPFでLinqを使用してSQLサーバーからExcelファイルをダウンロードするために使用している以下のクラスがあります。メソッドを機能させるのに問題があります。

public class Tables
            {
                public Guid Id { get; set; }
                public byte[] Data { get; set; }
                public string Notes{ get; set; }            
            }

財産

public ObservableCollection<Tables> Table
        {
            get
            {
                return mTables;
            }
        }

メソッド (エラー - fileBytes は現在のコンテキストに表示されません)

 private void executeSaveAttachment(object parameter)
            {
                //Enables the apperance of a Dialog, where the user can specify where to save the file
                SaveFileDialog textDialog = new SaveFileDialog();

                //save the file in a bite array

               // byte[] fileBytes = Table.ToList().ForEach(p => p.Data);
                Table.ToList().ForEach(p =>
                {
                    byte[] fileBytes = p.Data;
                });

                //Open dialog where the user determines where to save the file.
                bool? result = textDialog.ShowDialog();
                if (result == true)
                {
                    using (Stream fs = (Stream)textDialog.OpenFile())
                    {
                        fs.Write(fileBytes, 0, fileBytes.Length);
                        fs.Close();
                    }
                }
            }
4

2 に答える 2