Καλώς ορίσατε στο dotNETZone.gr - Σύνδεση | Εγγραφή | Βοήθεια

 

Αρχική σελίδα Ιστολόγια Συζητήσεις Εκθέσεις Φωτογραφιών Αρχειοθήκες

System.IO.FileInfo.Replace Method

  •  18-07-2008, 17:21

    System.IO.FileInfo.Replace Method

    Προσπαθώντας να εξετάσω πως δουλεύει η μέθοδος 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

    Δημοσίευση στην κατηγορία: , , ,
Δείτε όλες τις δημοσιεύσεις της Θεματική Ενότητας
Με χρήση του Community Server (Commercial Edition), από την Telligent Systems