|
-
Apr 16th, 2003, 09:21 AM
#1
Thread Starter
Frenzied Member
Floppy Drive
Yeah, i know. Floppy drives are so 90's. But i still have a question.
Why can't i check if a floppy is in the drive? Take a look at this code:
VB Code:
Public Function fc_VerifyDirectory(ByVal sDirectory As String) As Boolean
sDirectory = sDirectory.Trim
If sDirectory = "" Then
fc_VerifyDirectory = False
Else
Try
If Dir(sDirectory, FileAttribute.Directory) > "" Then fc_VerifyDirectory = True
Catch
fc_VerifyDirectory = False
End Try
End If
End Function
It's a basic function to check if a directory exists. Give it a shot. Place a floppy in the drive, and call the function passing in "A:\". You'll get back False. Try it again with "C:\" and it returns True.
Strange?
~Peter

-
Apr 16th, 2003, 12:57 PM
#2
Member
You can check if floppy in the drive by calling fictisious file and catching an error
Code:
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
#End Region
Dim Retries As Short = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
PictureBox1.Image = System.Drawing.Bitmap.FromFile("a:\fileopen.bmp")
Catch
MsgBox("Please insert the disk in drive A!")
End Try
End Sub
End Class
-
Apr 16th, 2003, 01:06 PM
#3
Frenzied Member
Your code returns true if the floppy contains any file and False if not. You even dont need to call for 'fictisious file' . Just make this change in your code.
VB Code:
Public Function fc_VerifyDirectory(ByVal sDirectory As String) As Boolean
sDirectory = sDirectory.Trim
If sDirectory = "" Then
fc_VerifyDirectory = False
Else
Try
Dim fd As DirectoryInfo = New DirectoryInfo(sDirectory)
fc_VerifyDirectory = fd.Exists
' If Dir(sDirectory, FileAttribute.Directory) > "" Then fc_VerifyDirectory = True
Catch
fc_VerifyDirectory = False
End Try
End If
End Function
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Apr 16th, 2003, 01:56 PM
#4
Thread Starter
Frenzied Member
-
Apr 16th, 2003, 02:02 PM
#5
Frenzied Member
PS: I hate floppy drives.
Why? Poor floppies. You know what good jobs still can be done by a single floppy?
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Apr 16th, 2003, 07:26 PM
#6
Sleep mode
Originally posted by Lunatic3
Why? Poor floppies. You know what good jobs still can be done by a single floppy?
Floppies are being replaced by Zips and USB Drives by the passing days as CDs by DVDs .
-
Apr 17th, 2003, 01:38 AM
#7
Frenzied Member
Still you can boot a computer and run an OS with only a floppy and no HD, and take advantage of it.
As CD's could not wipe out Cassetes totally ( I still use LPs ) I dont think DVD would wipe out CD and Zip drivers floppies.
Last edited by Lunatic3; Apr 17th, 2003 at 01:45 AM.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
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
|