|
-
Dec 29th, 2010, 12:24 AM
#1
Thread Starter
New Member
Retrieving Folder Size
Hello All,
I'm teaching myself some VB and decided the best way was to just dive in and start developing some useful personal apps. However, I am running into an issue when retrieving a folder size.
'This does not work when I insert %TMP%, If I insert an actual path like C:\Temp, it works fine.
objFolder = objFSO.GetFolder("%TMP%")
Am I missing an import or something? I currently have no imports. Any help would be appreciated.
-
Dec 29th, 2010, 12:45 AM
#2
Re: Retrieving Folder Size
There is no path called %TMP%
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Dec 29th, 2010, 12:57 AM
#3
Thread Starter
New Member
Re: Retrieving Folder Size
 Originally Posted by weirddemon
There is no path called %TMP%
Not True, There is an environmental variable path for %TMP% and %TEMP%. The problem is I do not think "program" can interperate the environmental variables because I am doing something wrong.
-
Dec 29th, 2010, 01:08 AM
#4
Re: Retrieving Folder Size
 Originally Posted by Infatuas
Not True, There is an environmental variable path for %TMP% and %TEMP%. The problem is I do not think "program" can interperate the environmental variables because I am doing something wrong.
No. You are incorrect. I'll say it again. There is no path called %TMP% or %TEMP%. An environmental variable is not a path. In the code you're using, its asking for an absolute path, not an environmental variable.
In your code you say, "here's the path I want you to look at", it looks at that path and finds nothing, because it isn't a path. You're telling it to look for a path, not an environmental variable.
If you want to use the latter, then specify it. I'm not at my computer, so I cant whip up an example. But if you look it up in MSDN (which is where you should always start) you'll be able to figure out how to use environmental variables in VB fairly quickly.
Last edited by weirddemon; Dec 29th, 2010 at 01:11 AM.
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Dec 29th, 2010, 01:12 AM
#5
Thread Starter
New Member
Re: Retrieving Folder Size
As I stated above, TMP is an environmental variable that I had to string out within Environ("TMP"). Problem Solved.
Dim tmpPATH As String
tmpPATH = Environ("TMP")
objFSO = CreateObject("Scripting.FileSystemObject")
objFolder = objFSO.GetFolder(tmpPATH)
-
Dec 29th, 2010, 01:19 AM
#6
Re: Retrieving Folder Size
 Originally Posted by Infatuas
As I stated above, TMP is an environmental variable that I had to string out within Environ("TMP"). Problem Solved.
Dim tmpPATH As String
tmpPATH = Environ("TMP")
objFSO = CreateObject("Scripting.FileSystemObject")
objFolder = objFSO.GetFolder(tmpPATH)
If you want to learn the language, then listen to what I'm saying and don't assume you know what you're talking about. If you did, you wouldnt be here.
Like I said, an environmental variable is NOT a path. It's an environmental variable. Which is why you used Environ to get it to work.
In the code you first used, you told the app to look for an absolute path and nothing more. By using Environ, your're now telling it to look for an environmental variable and not a path.
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Dec 29th, 2010, 03:49 AM
#7
Re: Retrieving Folder Size
My two cents...
Instead of going the VB6.0 workaround way use the .NET framwork
Like:
Code:
Dim FldInfo As IO.DirectoryInfo
Dim Path As String = My.Computer.FileSystem.SpecialDirectories.Temp
FldInfo = New DirectoryInfo(Path)
THe specialdirectories is also the way to find the desktopfolder etc...
Have Fun
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
-
Dec 29th, 2010, 07:52 AM
#8
Re: Retrieving Folder Size
 Originally Posted by Dnereb
My two cents...
Instead of going the VB6.0 workaround way use the .NET framwork
Like:
Code:
Dim FldInfo As IO.DirectoryInfo
Dim Path As String = My.Computer.FileSystem.SpecialDirectories.Temp
FldInfo = New DirectoryInfo(Path)
THe specialdirectories is also the way to find the desktopfolder etc...
Have Fun
I am guessing that the OP is using FSO because it has a size property for an entire folder.
-
Dec 29th, 2010, 10:40 AM
#9
Thread Starter
New Member
Re: Retrieving Folder Size
 Originally Posted by weirddemon
If you want to learn the language, then listen to what I'm saying and don't assume you know what you're talking about. If you did, you wouldnt be here.
Like I said, an environmental variable is NOT a path. It's an environmental variable. Which is why you used Environ to get it to work.
In the code you first used, you told the app to look for an absolute path and nothing more. By using Environ, your're now telling it to look for an environmental variable and not a path.
Now, this would have been a better suited initial response from you if you had full intensions of "training" someone with explanation and not just stating, "Path doens't exist". Thank you anyways.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|