Click here to Skip to main content
15,895,656 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionurgent! transfering connection of winsock to another process [modified] Pin
steve_ino27-Jul-06 7:44
steve_ino27-Jul-06 7:44 
QuestionHow to get information about/from controls in another process Pin
oakleaf27-Jul-06 6:03
oakleaf27-Jul-06 6:03 
AnswerRe: How to get information about/from controls in another process Pin
Tyquaun Hunter27-Jul-06 15:48
Tyquaun Hunter27-Jul-06 15:48 
QuestionConnecting sql server Pin
chn_babu27-Jul-06 3:56
chn_babu27-Jul-06 3:56 
AnswerRe: Connecting sql server Pin
alien viper27-Jul-06 20:23
alien viper27-Jul-06 20:23 
Questioncalculating the size of all the files present in a folder Pin
harish13927-Jul-06 2:00
harish13927-Jul-06 2:00 
AnswerRe: calculating the size of all the files present in a folder Pin
Colin Angus Mackay27-Jul-06 2:21
Colin Angus Mackay27-Jul-06 2:21 
AnswerRe: calculating the size of all the files present in a folder [modified] Pin
Tyquaun Hunter27-Jul-06 14:46
Tyquaun Hunter27-Jul-06 14:46 
To simplify the steps, I have created two functions you can use.

1. The first function will get all files in specified directory. You will need to add them all up to get a total folder size.

2. The second function will convert from bytes to kilobytes.

* Note: I am not sure if you are using vb.net or asp.net. I used Vb.Net so you will see a message box in my first function

Enjoy!

'Get File sizes in directory
Public Shared Sub GetFilesSizesInDirectory(ByVal Dir As String)
'Declare a variable to recieve file name
Dim FileName As String
'Iterate through specified directory
For Each FileName In Directory.GetFiles(Dir)
'Get file info and out file size
Dim Info As FileInfo = New FileInfo(FileName)
MsgBox(FileName & " " & ToKilobytes(Info.Length) & " KB")
Next
End Sub

'Convert from bytes to kilobytes
Public Shared Function ToKilobytes(ByVal Key As Long) As Long
'Variable to recieve remainder
Dim Remainder As Long
'Result of calculation
Dim Result As Integer = Math.DivRem(Key, 1024, Remainder)
'If there is a remainder always round-up
If Remainder <> 0 Then
Result += 1
End If
Return Result
End Function

Tyquaun


-- modified at 22:53 Thursday 27th July, 2006
GeneralRe: calculating the size of all the files present in a folder Pin
Colin Angus Mackay27-Jul-06 16:12
Colin Angus Mackay27-Jul-06 16:12 
GeneralRe: calculating the size of all the files present in a folder [modified] Pin
Tyquaun Hunter27-Jul-06 16:39
Tyquaun Hunter27-Jul-06 16:39 
GeneralRe: calculating the size of all the files present in a folder Pin
harish13927-Jul-06 19:27
harish13927-Jul-06 19:27 
QuestionConvert Binary Data to comma delimited text string Pin
VK-Cadec27-Jul-06 1:57
VK-Cadec27-Jul-06 1:57 
AnswerRe: Convert Binary Data to comma delimited text string Pin
RichardBerry27-Jul-06 2:52
RichardBerry27-Jul-06 2:52 
GeneralRe: Convert Binary Data to comma delimited text string Pin
Guffa27-Jul-06 7:26
Guffa27-Jul-06 7:26 
QuestionHowTo copy a folder with its contents to a target folder? Pin
Zaegra27-Jul-06 1:13
Zaegra27-Jul-06 1:13 
AnswerRe: HowTo copy a folder with its contents to a target folder? [modified] Pin
Tyquaun Hunter27-Jul-06 16:37
Tyquaun Hunter27-Jul-06 16:37 
GeneralRe: HowTo copy a folder with its contents to a target folder? Pin
Zaegra27-Jul-06 21:06
Zaegra27-Jul-06 21:06 
GeneralRe: HowTo copy a folder with its contents to a target folder? Pin
Zaegra27-Jul-06 21:11
Zaegra27-Jul-06 21:11 
AnswerRe: HowTo copy a folder with its contents to a target folder? Pin
Tyquaun Hunter28-Jul-06 4:27
Tyquaun Hunter28-Jul-06 4:27 
GeneralRe: HowTo copy a folder with its contents to a target folder? Pin
Zaegra5-Aug-06 21:07
Zaegra5-Aug-06 21:07 
GeneralRe: HowTo copy a folder with its contents to a target folder? Pin
Tyquaun Hunter10-Aug-06 15:57
Tyquaun Hunter10-Aug-06 15:57 
GeneralRe: HowTo copy a folder with its contents to a target folder? Pin
Zaegra16-Aug-06 22:45
Zaegra16-Aug-06 22:45 
QuestionBind a data set in an HTML table Pin
coolpali_girl27-Jul-06 0:30
coolpali_girl27-Jul-06 0:30 
AnswerRe: Bind a data set in an HTML table Pin
Tyquaun Hunter27-Jul-06 18:01
Tyquaun Hunter27-Jul-06 18:01 
GeneralRe: Bind a data set in an HTML table Pin
coolpali_girl29-Jul-06 0:57
coolpali_girl29-Jul-06 0:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.