您好,我有以下课程,我正在使用 WPF 中的 Linq to Sql 从 sql server 下载 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();
}
}
}