Προσπαθώντας να εξετάσω πως δουλεύει η μέθοδος FileInfo.Replace αντιμετωπίζω την εξής συμεριφορά. FileIOException The process cannot access the file because it is being used by another process. Θα μπορούσε κάποιος να με βοηθήσει; (Ο κώδικας τρέχει σε WinXP Pro Sp2 με Administrator rights & VS2005). Ευχαριστώ.
Private Sub ReplaceFile()
Dim originalFile As String = "D:\test1.txt"
Dim fileToReplace As String = "D:\test2.txt"
Dim backUpOfFileToReplace As String = "D:\test2.txt.bak"
If File.Exists(originalFile) AndAlso File.Exists(fileToReplace) Then
Dim fInfo As New FileInfo(originalFile)
If Not fInfo.IsReadOnly Then
fInfo.Replace(originalFile, fileToReplace) 'The process cannot access the file because it is being used by another process.
End If
End If
End Sub