Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Limitation in the System.IO.FileInfo.get_Length()
Message
From
05/03/2010 04:02:37
 
 
To
05/03/2010 03:41:40
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01452685
Message ID:
01452698
Views:
45
This message has been marked as a message which has helped to the initial question of the thread.
>>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 ?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform