By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,699 Members | 1,372 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,699 IT Pros & Developers. It's quick & easy.

File Access

P: n/a
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.

Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
Nov 21 '05 #2

P: n/a
Tried the example below, but still receive the same error message after the
"move"

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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

Nov 21 '05 #3

P: n/a
George,

On what line you get the error while debugging?
This can be on every line you know.
Cor
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.