vgaul Posted February 3, 2003 Posted February 3, 2003 Haven't seen this problem in the forums. If the solution is there, please point me to it. I have written an application and distributed it to a few family members. On some machines the application starts out with an error message: Titlebar: WindowsFormsParkingWindow: myProg.exe - No Disk There is no disk in the drive. Please insert a disk into Drive A: (Cancel, Try Again, Continue) This doesn't occur on all machines--just some. OS doesn't seem to matter: works OK on some XP machines, error on others; works OK on some Win2K machines, error on others. Unfortunately, none of the machines with errors have VB.Net installed so I can't step through the code. My code does not reference the floppy at (explicitly) but it does populate a combo box with drive letters using Directory.GetLogicalDrives(). I also use an FSO to get the available drive space, but again never reference the A: drive directly. Thoughts? Sidebar: Is there a way to get the available space without FSO that's fairly simple? Quote
*Experts* Volte Posted February 3, 2003 *Experts* Posted February 3, 2003 Try looking here: http://www.allapi.net/apilist/GetDiskFreeSpace.shtml Quote
vgaul Posted February 3, 2003 Author Posted February 3, 2003 Looks like VB6 code. Can all that still be used? The FSO technique was quick. Is there a problem using FSO in VB? Read somewhere it should only be used in scripts. Could it be causing my problem? Quote
*Experts* Volte Posted February 3, 2003 *Experts* Posted February 3, 2003 It's an API that can be used in any language supporting them (including .NET). Here is an example of enumerating all the drives and printing them and their free spaces: Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, ByRef lpSectorsPerCluster As Integer, ByRef lpBytesPerSector As Integer, ByRef lpNumberOfFreeClusters As Integer, ByRef lpTtoalNumberOfClusters As Integer) As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim drives() As String = IO.Directory.GetLogicalDrives() Dim drv As String For Each drv In drives Dim spc, bps As Long Dim free, total As Long Dim freeBytes, totalBytes As Long GetDiskFreeSpace(drv, spc, bps, free, total) freeBytes = spc * bps * free totalBytes = spc * bps * total ListBox1.Items.Add(drv & " Space: " & freeBytes & " / " & totalBytes) Next End Sub Quote
vgaul Posted February 4, 2003 Author Posted February 4, 2003 V.F. Thanks. API calls were things I never got a good handle on in VB6. Gonna study that link you gave me some more. One thing I've learned about programming--the more you learn, the more you realize you don't know. Thanks for your help. V.G. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.