Results 1 to 7 of 7

Thread: Floppy Drive

  1. #1

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Thumbs down 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:
    1. Public Function fc_VerifyDirectory(ByVal sDirectory As String) As Boolean
    2.         sDirectory = sDirectory.Trim
    3.         If sDirectory = "" Then
    4.             fc_VerifyDirectory = False
    5.         Else
    6.             Try
    7.                 If Dir(sDirectory, FileAttribute.Directory) > "" Then fc_VerifyDirectory = True
    8.             Catch
    9.                 fc_VerifyDirectory = False
    10.             End Try
    11.         End If
    12.     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


  2. #2
    Member
    Join Date
    Dec 2002
    Location
    NY, USA
    Posts
    52
    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
    Iouri Boutchkine

  3. #3
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    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:
    1. Public Function fc_VerifyDirectory(ByVal sDirectory As String) As Boolean
    2.         sDirectory = sDirectory.Trim
    3.         If sDirectory = "" Then
    4.             fc_VerifyDirectory = False
    5.         Else
    6.             Try
    7.                 Dim fd As DirectoryInfo = New DirectoryInfo(sDirectory)
    8.                
    9.                    fc_VerifyDirectory = fd.Exists
    10.                 ' If Dir(sDirectory, FileAttribute.Directory) > "" Then fc_VerifyDirectory = True
    11.             Catch
    12.                 fc_VerifyDirectory = False
    13.             End Try
    14.         End If
    15.     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

  4. #4

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Thumbs up

    Once i added the required import ( Imports System.IO ), it worked great! Thanks guys.

    PS: I hate floppy drives.
    ~Peter


  5. #5
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    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

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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 .

  7. #7
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    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
  •  



Click Here to Expand Forum to Full Width