我将文件流文档保存在NTFS中。每次我尝试使用下面的代码块访问它们时,在Image.FromStream行上都会收到“参数无效”的错误消息。这是否与FS文件夹中存储的文件有关?还是我的参数遗漏了什么?有没有办法查看文件夹中的文件以验证它们的格式是否正确?
private static Image LoadPhotoImage(string filePath, byte[] txnToken)
{
Image photo;
try
{
using (SqlFileStream sfs =
new SqlFileStream(filePath, txnToken, FileAccess.Read))
{
photo = Image.FromStream(sfs,false);
sfs.Close();
}
return photo;
}
catch (ArgumentException ae)
{
System.Diagnostics.Debug.WriteLine(ae.Message);
return null;
}
}发布于 2011-11-22 01:36:46
根据MSDN Documentation,您不能使用SqlFileStream实现此目的:
“SqlFileStream类用于处理SQL Server 2008数据库中使用FILESTREAM属性存储的varbinary(max)数据。”
只需使用Image.FromFile加载图像即可。
https://stackoverflow.com/questions/8215927
复制相似问题