473,385 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Long path/file names problem

PG
I am reading a directory using FileInfo Class. Have an exception
"PathTooLongException" error and would like to catch the name of the file and
its path that is throwing the exception. Thanks a lot for any help.
Public Function DirectorySize(ByVal dirinfo As DirectoryInfo) As Long
Try
Dim dirSize As Long = 0
' Add file sizes.
Dim AllFiles As FileInfo() = dirinfo.GetFiles()
Dim FileSysInfo As FileInfo
Dim strTemp As String

For Each FileSysInfo In AllFiles
strTemp = FileSysInfo.DirectoryName
dirSize += FileSysInfo.Length
Next FileSysInfo
' Add subdirectory sizes.
Dim AllDirs As DirectoryInfo() = dirinfo.GetDirectories()
Dim DirSysInfo As DirectoryInfo
For Each DirSysInfo In AllDirs
dirSize += DirectorySize(DirSysInfo)
Next DirSysInfo
Return dirSize
Catch strTemp As PathTooLongException
' This is where I would like to catch the offending culprit.
End Try
End Function 'DirSize
Jul 21 '05 #1
0 1346

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: David P. Jessup | last post by:
Lets see if I can explain this so I can get a good answer =) I'm trying to speed up a file search via FSO. I have a database that contains the exact path where files can be found and an "index"...
34
by: Reinhold Birkenfeld | last post by:
Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. It still can be found in CVS:...
6
by: Stephen Cook | last post by:
Having worked through the problems around enabling the document function using an XmlUrlResolver I started work on building a useful class to hide the intricacies. Trying to generalise the process...
0
by: Arjan van den Noort | last post by:
How to delete a directory (with all containing directories and files) with vb.net if the directory contains long paths ? (just like the dos command: RD /S/Q path) What I want is a routine to...
0
by: PG | last post by:
I am reading a directory using FileInfo Class. Have an exception "PathTooLongException" error and would like to catch the name of the file and its path that is throwing the exception. Thanks a lot...
3
by: Zenu | last post by:
Hi, I have a system with very long paths and I'm trying to use file.exist(Longpath) to test the paths existance but it gives a message that the path is too long. Can someone tell me how to...
4
by: Ben | last post by:
Hi We have a list of file paths and short file names in our database. We need to loop through them all, picking up the long file name from the file itself and check that the long file name...
5
by: Martin Carpella | last post by:
Hi! I know, that Path-names should be shorter than MAX_PATH (250), but the Win32-SDK allows specifiying longer names using the "\\?\" prefix. As I have an application that accesses files...
5
by: =?Utf-8?B?SmVmZiBCZWVt?= | last post by:
Before you respond with "just use GetShortPathName" please read the rest. We have an application that places files on a file server using mapped drives as it's path of choice. The reason for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.