Wrox Programmer Forums
|
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 22nd, 2008, 05:25 AM
Authorized User
 
Join Date: Apr 2008
Posts: 85
Thanks: 10
Thanked 0 Times in 0 Posts
Default The process cannot access the file

Hi All,

I have a situtation my application is running on windows 2003 server which is a domain and in web.config

<Identity impersonation=true username=ABC\XYZ password=******>

what i am doing in the code that i take folder path from user and retrive all file information from that folder and writing to a CSV file which i am creating

using StreamWriter.

Dim objSW As StreamWriter = New StreamWriter("MMLIVFILTRE_080721_165835.CSV")

Problem is when user enter path like : 'C:\Foldername' then it is working fine and writing all the files informatin in to the file which is created by streamwriter.

but when user enter path : '\\servername\c$\foldername' then is is giving me the below error

Exception: System.IO.IOException: The process cannot access the file 'D:\MMLIVFILTRE_080721_165835.CSV' because it is being used by another process.

 'MMLIVFILTRE_080721_165835.CSV' in this file i am writing the information which is created by streamwiter.

can u tell me why this error is occuring. please tell me wher i am doing wrong ?

Thanks

-nelly


 
Old July 22nd, 2008, 05:30 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Well if it says it is in use by another user then it is probably in use by another user.

Are you sure you are issuing objSW.Close() after you have finished writing to the file?

/- Sam Judson : Wrox Technical Editor -/
 
Old July 22nd, 2008, 06:01 AM
Authorized User
 
Join Date: Apr 2008
Posts: 85
Thanks: 10
Thanked 0 Times in 0 Posts
Default

Hi Sam,

Thanks for your quick reply, yes i am closing and desposing the object.

objSW.Close()
objSW.Dispose()
objSW = Nothing



 
Old July 22nd, 2008, 06:59 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

And what about processes that might read from the file? Or virus scanning software? Or any other number of things that might try to open the file... for reading or writing?

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
The process cannot access the file... DolphinBay ASP.NET 1.0 and 1.1 Professional 9 May 23rd, 2014 04:38 AM
The process cannot access the file while publishin madhu15583 ASP.NET 1.0 and 1.1 Professional 0 June 19th, 2008 01:58 AM
[Resolved] Error: File used by another process snufse .NET Framework 2.0 2 February 18th, 2008 09:20 AM
file error ...being used by another process rreynolds Pro VB.NET 2002/2003 6 January 11th, 2005 11:56 AM
DTS text file export - Batch Process Tim Barbour SQL Server DTS 1 November 23rd, 2004 11:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.