troubleshooting Question

C#.Net: The file is being used by another process

Avatar of MohitPandit
MohitPanditFlag for India asked on
.NET ProgrammingC#ASP.NET
14 Comments3 Solutions1788 ViewsLast Modified:
Hello,

I've a WCF and a Window service, which access same .CSV file. Like, WCF generates a request and placed new request in .CSV file and once request is generated then window service invoked for process the request.

If I created one by one request then it doesn't show any problem.
But when I generate request in loop like 10000 request then sometime it shows below error while generating request:
"The file is being used by another process"

FYI,
At WCF end:
I've used File Stream and Stream writer like this
--> using (FileStream fs = new FileStream(ConfigurationSettings.AppSettings["CSVFilePath"] + "\\" + fileName, FileMode.Append))

--> of course, I am doing flush and close Stream writer.

At Window Service end: I've used
Microsoft.Jet.OLEDB.4.0

string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
connectionString += requestFile.DirectoryName;
connectionString += ";Mode=Share Deny None;Extended Properties=" + "\"" + "text;HDR=YES;FMT=Delimited" + "\"";

Like you can see, Mode is Share Deny None.

Do you have your great thoughts?

Kindly remember, when I generate a huge request in loop like 1000, 5000 or 10000 then I receive this request else not.

Best Regards,
Mohit Pandit
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 3 Answers and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros