![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | The process cannot access the file I have an application that is working on WindowsXP and Windows2000. I recently moved it onto a new Windows2003 Server Service Pack 2 machine. It is now getting an error message which reads "The process cannot access the file <filename> because it is being used by another process" this is what I have (abreviated version): If File.Exist(FullPathName) Then Dim sr As StreamReader = File.OpenText(FullPathName) Dim sw As StreamWriter = File.CreateText(NewFullPathName) ... do some work sw.Flush() sw.Close() sr.Close() File.Delete(FullPathName) File.Move(NewFullPathName, FullPathName) End If |
My System Specs![]() |
| | #2 (permalink) |
| | Re: The process cannot access the file spunkopolis wrote: Quote: > I have an application that is working on WindowsXP and Windows2000. I > recently moved it onto a new Windows2003 Server Service Pack 2 > machine. It is now getting an error message which reads "The process > cannot access the file <filename> because it is being used by another > process" so that its previous invocation has left a lock on one of the files? Quote: > this is what I have (abreviated version): > > If File.Exist(FullPathName) Then > Dim sr As StreamReader = File.OpenText(FullPathName) > Dim sw As StreamWriter = File.CreateText(NewFullPathName) e.g. with FileShare.Read. Quote: > ... do some work > > sw.Flush() Quote: > sw.Close() > sr.Close() > > File.Delete(FullPathName) > File.Move(NewFullPathName, FullPathName) > End If Andrew |
My System Specs![]() |
| | #3 (permalink) |
| | Re: The process cannot access the file It is the Input File, never makes it to output file. Since the output file does not exist and is being created, would it be possible for this error to be raised? The program did not crash nor does it attempt to open the file before this point. DID I MENTION THAT THIS IS WORKING ON XP AND 2000 SERVER PLATFORMS? On 5/18/09 3:13 AM, in article 77cqm4F1guio5U1@xxxxxx, "Andrew Morton" <akm@xxxxxx-press.co.uk.invalid> wrote: Quote: > spunkopolis wrote: Quote: >> I have an application that is working on WindowsXP and Windows2000. I >> recently moved it onto a new Windows2003 Server Service Pack 2 >> machine. It is now getting an error message which reads "The process >> cannot access the file <filename> because it is being used by another >> process" > Would the be the input or output file? Did your program crash at some time > so that its previous invocation has left a lock on one of the files? > Quote: Quote: >> this is what I have (abreviated version): >> >> If File.Exist(FullPathName) Then >> Dim sr As StreamReader = File.OpenText(FullPathName) >> Dim sw As StreamWriter = File.CreateText(NewFullPathName) > You can use a New FileStream to get more options as to how to open the file, > e.g. with FileShare.Read. > Quote: >> ... do some work >> >> sw.Flush() > Not needed, because .Close() flushes the stream. > Quote: >> sw.Close() >> sr.Close() >> >> File.Delete(FullPathName) >> File.Move(NewFullPathName, FullPathName) >> End If > HTH > > Andrew > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Elevated process can't write to %temp% - access denied ? | Vista General | |||
| Elevated process can't write to %temp% - access denied ? | Vista security | |||
| open a file, wait for user to amend file, close & process | PowerShell | |||
| Failover Guest Cluster -- 'The process cannot access the file becauseit is being used by another process.' | Virtual Server | |||
| Re: The Process cannot access the file ... | PowerShell | |||