Click here to Skip to main content
16,005,697 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Call module with argument Pin
Mekong River13-Nov-04 4:21
Mekong River13-Nov-04 4:21 
QuestionDatakey for VB datagrid? Pin
Craig C.12-Nov-04 8:30
Craig C.12-Nov-04 8:30 
AnswerRe: Datakey for VB datagrid? Pin
Craig C.15-Nov-04 7:12
Craig C.15-Nov-04 7:12 
GeneralRe: Found it! Pin
Craig C.15-Nov-04 9:48
Craig C.15-Nov-04 9:48 
Generalcall card telephony solution! Pin
manasrahfantom12-Nov-04 8:18
manasrahfantom12-Nov-04 8:18 
GeneralRe: call card telephony solution! Pin
Mekong River13-Nov-04 4:27
Mekong River13-Nov-04 4:27 
GeneralFreespace Pin
KreativeKai12-Nov-04 5:02
professionalKreativeKai12-Nov-04 5:02 
GeneralRe: Freespace Pin
Dennis C. Dietrich12-Nov-04 17:02
Dennis C. Dietrich12-Nov-04 17:02 
Hello Kai!

Does anyone have any sample code where they look up how much space a file will take and then check how much space is available on the target drive the file is going to be transfered to?

I'm afraid my suggestion requires the .NET Framework 2.0 but with the new classes the solution is quite easy. Use the DriveInfo.AvailableFreeSpace[^] property to determine how much space is available to you. If it's at least the size of your file (to get that information you can use the FileInfo.Length[^] property) you call FileCopy[^].
Imports System.IO

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
                              ByVal e As System.EventArgs) Handles Button1.Click
        Dim MyDrive As DriveInfo = New DriveInfo("A")
        Dim MyFile As FileInfo = New FileInfo("C:\boot.ini")
        If MyDrive.AvailableFreeSpace >= MyFile.Length Then
            FileCopy(MyFile.FullName, _
                     MyDrive.RootDirectory.ToString() + MyFile.Name)
        End If
    End Sub
End Class

If you're using the .NET Framework 1.1 it seems you will have to use the WMI (see Finding the Amount of Disk Space Available (Visual Basic)[^]).

Best regards
Dennis
GeneralRe: Freespace Pin
KreativeKai15-Nov-04 7:18
professionalKreativeKai15-Nov-04 7:18 
GeneralEdit box focus Pin
Red Sunday12-Nov-04 3:38
Red Sunday12-Nov-04 3:38 
GeneralRe: Edit box focus Pin
MohammadAmiry12-Nov-04 5:01
MohammadAmiry12-Nov-04 5:01 
GeneralRe: Edit box focus Pin
Mekong River13-Nov-04 4:31
Mekong River13-Nov-04 4:31 
GeneralRe: Edit box focus Pin
MohammadAmiry14-Nov-04 22:48
MohammadAmiry14-Nov-04 22:48 
GeneralRe: Edit box focus Pin
Mekong River15-Nov-04 13:27
Mekong River15-Nov-04 13:27 
GeneralDownloading files & VB6 Pin
RichardGrimmer12-Nov-04 0:21
RichardGrimmer12-Nov-04 0:21 
GeneralString Arrays Pin
beowulfagate11-Nov-04 22:50
beowulfagate11-Nov-04 22:50 
GeneralRe: String Arrays Pin
MohammadAmiry12-Nov-04 2:13
MohammadAmiry12-Nov-04 2:13 
GeneralRe: String Arrays Pin
beowulfagate12-Nov-04 13:33
beowulfagate12-Nov-04 13:33 
GeneralRe: String Arrays Pin
Dennis C. Dietrich12-Nov-04 16:13
Dennis C. Dietrich12-Nov-04 16:13 
GeneralLasso with vb.net Pin
arttut0211-Nov-04 22:26
arttut0211-Nov-04 22:26 
GeneralRe: Lasso with vb.net Pin
MohammadAmiry12-Nov-04 6:22
MohammadAmiry12-Nov-04 6:22 
GeneralDisplay record on the webpage Pin
Mekong River11-Nov-04 16:33
Mekong River11-Nov-04 16:33 
GeneralRe: Display record on the webpage Pin
Tom John11-Nov-04 21:21
Tom John11-Nov-04 21:21 
Generaltranslating vb6 code to vb.net 2003 code Pin
Anonymous11-Nov-04 5:50
Anonymous11-Nov-04 5:50 
GeneralRe: translating vb6 code to vb.net 2003 code Pin
Daniel Turini11-Nov-04 7:34
Daniel Turini11-Nov-04 7:34 

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.