1
全部。我在Silverlight应用程序中上传文件时遇到问题。这是一个代码示例。如果在其他应用程序(例如excel或word)中打开此文件,则无法打开它,否则它工作正常。我使用OpenFileDialog
来选择文件并将其传递给此函数。Silverlight文件上传 - 文件正在被其他进程使用(Excel,Word)
private byte[] GetFileContent(FileInfo file)
{
var result = new byte[] {};
try
{
using (var fs = file.OpenRead())
{
result = new byte[file.Length];
fs.Read(result, 0, (int)file.Length);
}
}
catch (Exception e)
{
// File is in use
}
return result;
}
有没有什么办法可以访问这个文件,或者我应该只是通知用户该文件被锁定?