Silverlight file upload - file is in use by another process (Excel, Word)
Posted
by walkor
on Stack Overflow
See other posts from Stack Overflow
or by walkor
Published on 2010-05-26T07:59:36Z
Indexed on
2010/05/26
8:01 UTC
Read the original article
Hit count: 295
Hi, all. I have a problem with uploading of the file in Silverlight application. Here is a code sample. In case when this file is opened in other application (excel or word for example) it fails to open it, otherwise it's working fine. I'm using OpenFileDialog to choose the file and pass it to this function.
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;
}
Is there any way i can access this file or should i just notify the user that the file is locked?
© Stack Overflow or respective owner