Iamthestig
Programmer
Hi,
I'm having a problem with moving word documents from one file to another.
I'm basically swapping 2 word docs around using a temp folder prevent any read/write conflicts. This works fine the first time it's run, but if I run it again I get a "The process cannot access the file because it is being used by another process." exception.
Now I understand this is because the File.Move creates a Winword process the first time which is still in use the second time it's run. I have played around with killing the process first but all open unrelated word docs will also be killed.
Any idea how I can identify and kill just the File.Move created process?
Thanks for looking.
John
I'm having a problem with moving word documents from one file to another.
Code:
If System.IO.File.Exists("Shared Files\CVs\Original CV\" & objContact.OrigCVFilename) And System.IO.File.Exists("Shared Files\CVs\" & objContact.CVFileName) Then
System.IO.File.Move("Shared Files\CVs\Original CV\" & objContact.OrigCVFilename, "C:\Program Files\TempCV\TempCV" & objContact.OrigCVFilename)
System.IO.File.Move("Shared Files\CVs\" & objContact.CVFileName, "Shared Files\CVs\Original CV\" & objContact.CVFileName)
System.IO.File.Move("C:\Program Files\TempCV\TempCV" & objContact.OrigCVFilename, "Shared Files\CVs\" & objContact.OrigCVFilename)
End If
I'm basically swapping 2 word docs around using a temp folder prevent any read/write conflicts. This works fine the first time it's run, but if I run it again I get a "The process cannot access the file because it is being used by another process." exception.
Now I understand this is because the File.Move creates a Winword process the first time which is still in use the second time it's run. I have played around with killing the process first but all open unrelated word docs will also be killed.
Any idea how I can identify and kill just the File.Move created process?
Thanks for looking.
John