File Access

  • Thread starter Thread starter George
  • Start date Start date
G

George

the following code


file.delete(filedetails)
Dim FileStream As StreamWriter = New StreamWriter(filedetails)


produces this error

The process cannot access the file "D:\data.txt" because it is being
used by another process.


Single user XP sp2 pro environment.

I have tried to sleep the process without success, any ideas would be
appreciated.
 
George,
file.delete(filedetails)
Dim FileStream As StreamWriter = New StreamWriter(filedetails)
Which one creates the error, I assume the first, because I assume that it is
still reading that one. (An often made mistake). I create it in that case
forever it more like this.

sr.close 'streamreader close
file.move(filedetails, mytempfile) 'renaming and saving
Dim FileStream As StreamWriter = New StreamWriter(filedetails)
and when it is ready
file.delete(mytempfile)

I hope this helps,

Cor
 
George,

On what line you get the error while debugging?
This can be on every line you know.


Cor
 

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

Back
Top