I offer users to download files using WCF Streams. Problem is that once file is downloaded (FileStream object is created) I can't delete that file with File.Delete(), it says it is being used by someone other. At client side after download I close stream. How to fix this?
Asked
Active
Viewed 714 times
0
-
How is your service and contract defined? – Ladislav Mrnka Sep 09 '11 at 14:30
-
At the client side, do you close/dispose the service proxy object? – Allon Guralnek Sep 09 '11 at 16:15
-
Sollution is to set FileShare parameter when creating FileStream to "FileShare.Delete | FileShare.Read" – mersadk Sep 09 '11 at 21:31
1 Answers
0
Your solution with "FileShare.Delete | FileShare.Read" is actually a workaround (the file handle will still not be closed). I suspect you use MessageContract that contains the Stream. In that case you have to actually do slightly more work to correctly dispose the stream, see this answer Stream as a return value in WCF - who disposes it?

Community
- 1
- 1

Peter Sladek
- 900
- 9
- 8