안녕하세요 저는 SQL Server에서 Linq를 사용하여 SQL에서 WPF의 Excel 파일을 다운로드하는 데 사용하고있는 아래 클래스가 있습니다. 방법을 작동시키는 데 문제가 있습니다.이진 쓰기 .XLSX
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();
}
}
}
가 아래에'if' 문장의 맥락에서 사용할 수 없습니다 귀하의'fileBytes' 배열은 루프 내에서 초기화를 들어. –