Click here to Skip to main content
15,919,341 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guys i am experiencing a problem with my file

i am checking if a file exist and if it exists then i want a streamwriter open

but the stream writing gives me a runtime error telling me the file is used by a other process?

C#
if (File.Exists(@"D:\Installs\Watchdog\Watchdog.log")){
sw = new System.IO.StreamWriter(@"D:\Installs\Watchdog\Watchdog.log", true);}


this is my code please help me

i romove the file exists then it works fine but how do i check then if the file exists?
Posted
Updated 18-Mar-10 22:46pm
v2

1 solution

Well, I guess your file is in use by another process. Is it yours ? I'd assume so. If you remove the File.Exists and it works, then File.Exists must be the lock, but I doubt it.
 
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