>>I don't understand. I think you need to post some code
>
>The correct location is when the loFile.Length is used, which is an object from FileInfo.
>
>Here is a portion of the code:
>
>
> loDirectoryInfo = New DirectoryInfo(cDirectory)
>
> Try
> loFiles = loDirectoryInfo.GetFiles(cFilter)
>
> ' Get all the files in the directory
> For Each loFile In loFiles
> loRow = oDataSet.Tables(0).NewRow
>
> loRow("Extension") = loFile.Extension
> loRow("LastUpdate") = loFile.LastWriteTime
> loRow("Name") = Trim(loFile.Name)
> loRow("Size") = loFile.Length
>
>
>So, the last line is where the problem is. As soon as I have a file name having more than 160 characters, loFile.Length will generate an error.
>
>And, it is not about the loRow("Size") field. I tried to dump loFile.Length into a double variable and it was the same.
This works for me:
Dim loDirectoryInfo As System.IO.DirectoryInfo
loDirectoryInfo = New System.IO.DirectoryInfo("d:\\tmp")
For Each loFile In loDirectoryInfo.GetFiles()
Dim l As Long = loFile.Length
Console.WriteLine("Name: {0} Length:{1}", loFile.FullName, loFile.Length)
Next
Also you said the error was 'could not find file' - seems odd that that would occur on the fourth reference to loFile rather than the first ?