Error on creating a text file to write lines

J

JenHu

Hi all,

I want to create a text file to write lines, but it gives me an error
on Dim sw As New StreamWriter(CreatePath & Efilename) :
System.IO.IOException: The process cannot access the file
"C:\temp\DD_01062005.txt" because it is being used by another
process.

Can someone point me out where did I do wrong? Thanks.

------------------------------------------------------------------
Dim CreatePath As String = "C:\temp\"
Dim Efilename As String = "DD_" & Format(Date.Today,
"MMddyyyy").ToString & ".txt"
File.Create(CreatePath & Efilename)
Dim sw As New StreamWriter(CreatePath & Efilename)

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
M

Marina

Sounds like you opened this file at some point, but never closed it. So it
is still locked by the other object you used to access it. Make sure you
always close any stream that accesses your file.

You will probably need to restart asp.net to release the file lock.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top