Click here to Skip to main content
15,920,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Helloo Everbody

I am trying to build an AV for my college project and during scanning I am getting exception-Access denied,file is used by another process and hence can't scan the file.I also used Fileshare.ReadWrite but of no use.It'mostly with C: drive files.
Posted
Updated 5-Dec-11 21:11pm
v2
Comments
D K N T H 6-Dec-11 2:57am    
what do you mean already by process? pls. clarify your question and be more specific.

If your file is not opened with SharedRead then you can't.

See here : File.Open Method (String, FileMode, FileAccess, FileShare)[^]
 
Share this answer
 
If your file is genuinely in use by another process, and the framework is complaining about that, then there is nothing you can do: the file is locked open for exclusive access and you cannot get at it's content.

If you application has opened it, and walked away, then it complains it is in use, then try Close-ing and Dispose-ing any File related items which opened it in the first place - streams and such - if you don't then they will hold an exclusive lock until the Garbage collector disposes of them for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900