Farmer
Farmer

Reputation: 10983

Write on Excel file while it is open by another user

I'm trying to edit an opened excel file (by another user in a shared network) in order to make some changes to it and save it back. But when I try to open the file I get the following error :

Message=The process cannot access the file      
'Y:\COMMON\SharedFolders\Export.xlsx', because it is being used by another process.
Source=mscorlib
StackTrace:
    à System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
    à System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
    à System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
    à System.IO.File.InternalReadAllBytes(String path, Boolean checkHost)
    à System.IO.File.ReadAllBytes(String path)
    à OfficeOpenXml.ExcelPackage.ReadFile()
    à OfficeOpenXml.ExcelPackage.ConstructNewFile(Stream stream, String password)
    à OfficeOpenXml.ExcelPackage..ctor(FileInfo newFile)

By the way, I'm using the EPPLUS library.

Upvotes: 0

Views: 577

Answers (2)

Ondrej Svejdar
Ondrej Svejdar

Reputation: 22054

You can't. That being said you can look into some "source-safe" solution (like svn, sharepoint or google docs). You can also implement some "poor man" source safe yourself - i.e. small web application that will act as proxy over file system & will allow you to upload file, list folder, download files.

Other option would be to delay update to date when no-one will be accessing that file.

Upvotes: 1

iTekExpert
iTekExpert

Reputation: 31

Google allow multiple edit at the same time... maybe you should try to move that file there if possible.

Upvotes: 0

Related Questions