0
db에 저장된 파일을 디스크의 파일로 저장하는 방법이 있습니다. 메서드를 수정하면 MemoryStream이 반환됩니다.SQL Server에서 C#의 메모리 스트림에 파일 저장
public static void databaseFileRead(string varID, string varPathToNewLocation) {
using (var varConnection = Locale.sqlConnectOneTime(Locale.sqlDataConnectionDetailsDZP))
using (var sqlQuery = new SqlCommand(@"SELECT [RaportPlik] FROM [dbo].[Raporty] WHERE [RaportID] = @varID", varConnection)) {
sqlQuery.Parameters.AddWithValue("@varID", varID);
using (var sqlQueryResult = sqlQuery.ExecuteReader()) {
if (sqlQueryResult != null) {
sqlQueryResult.Read();
var blob = new Byte[(sqlQueryResult.GetBytes(0, 0, null, 0, int.MaxValue))];
sqlQueryResult.GetBytes(0, 0, blob, 0, blob.Length);
using (var fs = new FileStream(varPathToNewLocation, FileMode.Create, FileAccess.Write)) {
fs.Write(blob, 0, blob.Length);
}
}
}
}
}
감사합니다. – MadBoy
다른 사람이 전체 코드를 붙여 넣을 수 있다면 우수 할 것입니다. 그래서 다른 사람들이 어떻게하는지 연구 할 수 있습니다 ... 또한 memorystream에 대한 경험이없고 Blob 파일에서 데이터를 가져 오는 젊은 프로그래머가 있습니다. – dovla091