我应该使用System.Data.SqlTypes.SqlFileStream来读写FILESTREAM列吗?
例如:
var sqlCommand = sqlConnection3.CreateCommand();
sqlCommand.CommandText = "Select FileData.PathName() As Path, GET_FILESTREAM_TRANSACTION_CONTEXT() As TransactionContext From PictureTable Where PkId = (Select Max(PkId) From PictureTable)";
var reader = sqlCommand.ExecuteReader();
reader.Read();
var filePath = (string)reader["Path"];
var transactionContext = (byte[])reader["TransactionContext"];
var sqlFileStream = new SqlFileStream(filePath, transactionContext, FileAccess.Read);
var data = new byte[sqlFileStream.Length];
sqlFileStream.Read(data, 0, Convert.ToInt16(sqlFileStream.Length));在上面的代码中,我可以使用这里显示的查询并直接访问FileData
Select FileData From PictureTable Where PkId = (Select Max(PkId) From PictureTable)如果不使用SqlFileStream而使用varbinary(max)读写会发生什么?
当SQL server和应用程序安装在不同的服务器上时,我在设置Windows身份验证以访问SqlFileStream文件路径时遇到一些问题。我怎样才能避免这个问题?
https://stackoverflow.com/questions/48042400
复制相似问题