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

Rename(old,new) issue with msgbox

P: n/a
I've been having the following issue with a windows
service I've created in vb.net (.net fw 1.1):

Basically, my service monitors a folder for the creation
of any new files of a particular type and renames them
using the "Rename(oldfilename,newfilename)" function.
Unfortunately, this function only seems to work if and
only if it is preceeded by a 'msgbox("<some text>")'.

ie. If I have the following the service sees the file
created in the folder and renames it appropriately:
MsgBox("e.name variable etemp is " & etemp)
Rename(etemp, NewFName) 'Rename the file

but if I comment out the 'msgbox' line and only have the
"Rename(etemp, NewFName) 'Rename the file"
line, the service only sees the file created but does not
rename it.

I've using System.IO.File.Move(etemp, NewFName) in place
of Rename but with the same results. I'm stumped as to
why the presence of a msgbox should cause my rename to
succeed or fail.

-ANY- help in this would be greatly appreciated.

Thanks,

Jay
jg********@scf.sk.ca
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Jay at SCA" <jg********@scf.sk.ca> wrote in news:2d2501c38e9c$e24cc430
$3*******@phx.gbl:
I'm stumped as to
why the presence of a msgbox should cause my rename to
succeed or fail.


I would guess that the service was trying to rename the file before it was
finished being written. Adding the MsgBox may have just taken up enough
extra time to allow the file to be completely written.

Instead of using a MsgBox, try using Thread.Sleep with various amounts of
time to see if that is the case.

Just a thought

Chris
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.