Avatar of CraigLazar
CraigLazar
 asked on

VB.net Get My Documents folder size on Win7

Hi,
I have a small exe that i has a routine in to work out the folder size. I need to work out the folder size of My Documents. Problem is that i think windows 7 security is a problem when my exe runs as it is not picking up the default folder My Documents under c:\Users\Craig\My Documents.

thanks a lot

cheers
Visual Basic.NETVisual C++.NETWindows 7

Avatar of undefined
Last Comment
CraigLazar

8/22/2022 - Mon
smilitaru

Hi,

How do you specify the My Documents folder in your code?
smilitaru

You should use: Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
CraigLazar

ASKER
Hi,
I have a class which iterates thru all the folders and sub folders on the c drive, in this process i have a simple If statement using INSTR function to look for My Documents
So it finds no match when i pass it C drive, i then have a My Documents on my D Drive which then my process picks it up.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Nasir Razzaq

With Win7 (and Vista may be), these folders are difficult to access directly (sometimes even in Explorer). You may have to add special conditions and logic for these folders.
ASKER CERTIFIED SOLUTION
smilitaru

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
CraigLazar

ASKER
Thanks so much for the sample code man, it is perfect tweeked it slightly :)