Rename Function tripping

ronin2307

Member
Joined
Mar 10, 2005
Messages
16
Programming Experience
1-3
Hi,

I am using the Rename function to rename and move files around, but it seems to be very inconsistant.
On the same set of files (just simple tiff files) I run the function and every so often it chokes with the following error message:

Procedure call or argument is not valid.

However, there seems to be nothing wrong with the file names or paths, and the funny thing is like I said that sometimes they work and sometimes they dont

Any help will be very appreciated

Thanx
 
VB.NET:
Private Sub btnRename_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRename.Click
        Dim strNewPath, strOldPath As String
        Try
            With DsFilesColl.Tables(0)
                For intCOunt As Integer = 0 To .Rows.Count - 1
                    If Not .Rows(intCOunt).Item(1) Is System.DBNull.Value Then
                        strOldPath = CType(.Rows(intCOunt).Item(0), String)
                        strNewPath = CType(.Rows(intCOunt).Item(2), String) & .Rows(intCOunt).Item(1) & ".tif"
                        Debug.WriteLine("OLD PATH: " & strOldPath)
                        Debug.WriteLine("NEW PATH: " & strNewPath)
                        Rename(strOldPath, strNewPath)
                    End If
                Next
            End With
        Catch ex As Exception
            Debug.WriteLine(ex.Message)
            MsgBox("ERROR")
        End Try
    End Sub
 
I don't see anything wrong with the code but I don't have the data to see if that's the problem.
Have you set breakpoints and stepped through the code checking the values of strOldPath and strNewPath?
 
Back
Top