Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

VB.Net file not found exception error.

Posted on 2006-04-27
7
Medium Priority
?
538 Views
Last Modified: 2012-06-21
when using the function below, on certain files, it will puke with an exception error saying file not found.  any ideas.

        Dim Size As Long = 0
        ' Add file sizes.
        Dim fis As FileInfo() = d.GetFiles()
        Dim fi As FileInfo
        Dim con As Console


        For Each fi In fis
            con.WriteLine(fi.Name)
            'con.WriteLine(fi.FullName)
            Try
                Size += fi.Length
            Catch er As Exception

            End Try

        Next fi

        ' Add subdirectory sizes.
        Dim dis As DirectoryInfo() = d.GetDirectories()
        Dim di As DirectoryInfo
        For Each di In dis
            Size += DirSize(di)
        Next di


        Return Size
    End Function 'DirSize
0
Comment
Question by:beaconlightboy
5 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16553926
You are making a recursive call to DirSize()....I think...

Can you show us the declaration for DirSize as well?

    Public Function DirSize(....?
0
 
LVL 3

Author Comment

by:beaconlightboy
ID: 16554561
yes.  its public function dirsize(byval d as directoryinfo) as long

0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 672 total points
ID: 16555498
I did my entire C: drive (took quite ahwhile...) with no errors.   =\

It came back with: 69921964800

0
 
LVL 3

Assisted Solution

by:pitster
pitster earned 664 total points
ID: 16555780
You may want to check the security settings of the files that are failing. If for instance you are not a local administrator of the machine and you are trying to access 'C:\Documents and Settings\SomeOtherUser' you may run into issues.


I hope this helps :)
0
 
LVL 3

Assisted Solution

by:yokkui
yokkui earned 664 total points
ID: 16575175
I agree with pitster. It should be related to file permissions. Moreover, I suggest you turn off "Simple File Sharing" folder option.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
No other job is as rewarding and demanding as building an iPhone app is. It is not really in the hands of the developer for the success of an iPhone app. Many factors operate jointly for every iOS application's success in the market.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question