writing to floppy and CD-R drives

In my application, I have a backup menu item, where when user clicks Backup, the Save dialog box appears. Saving to the hard drive works fine, but when i save to the floppy and CD-R drive i get errors.
Floppy: Method 'CopyFile' of object 'IFileSystem3' failed
CD: Run-time erro: '71': Disk not ready

here is my code for the backup:
Private Sub mnuBackup_Click()
    Dim fs As Object
    Dim varFileName, fsFolder, fsPath, fsFileName As String
   
    comDlgBackup.ShowSave
    varFileName = comDlgBackup.FileName
   
    Set fs = CreateObject("Scripting.FileSystemObject")
    fsFolder = fs.getparentfoldername(varFileName)
    fsFileName = fs.getfilename(varFileName)
   
    If fsFolder = "a:\" Or fsFolder = "e:\" Then fsPath = fsFolder + fsFileName Else fsPath = fsFolder + "\" + fsFileName
    fs.copyfile "C:\Cutbank - VB6\data.mdb", fsPath
End Sub

i would just like them to do an ordinary save. For the CD-R drive, i'd like the file to be copied over and Windows will alert me that there are files to be written unto disk (just like what XP does when you copy/write to disk).

thanks in advance to anyone who can help!
joyful88Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
Something like this

    If fsFolder = "a:\"  Then
        fsPath = fsFolder + fsFileName
    Else if fsFolder = "e:\" then
        msgbox "There are files to copy to a CD.  Please insert the disk"
        fsPath = fsFolder + fsFileName
    else
        fsPath = fsFolder + "\" + fsFileName
    end if

    fs.copyfile "C:\Cutbank - VB6\data.mdb", fsPath

mlmcc
0
bhagyeshtCommented:
Private Sub mnuBackup_Click()
    Dim fs As Object
    Dim varFileName, fsFolder, fsPath, fsFileName As String
   
    comDlgBackup.ShowSave
    varFileName = comDlgBackup.FileName
    Set fs = CreateObject("Scripting.FileSystemObject")
NoDisk:    
    if err.number<>0 then
        err.clear
        Msgbox "Insert Disk in medium"
    end if
    fsFolder = fs.getparentfoldername(varFileName)
    fsFileName = fs.getfilename(varFileName)
    on error goto NoDisk
    If fsFolder = "a:\" Or fsFolder = "e:\" Then fsPath = fsFolder + fsFileName Else fsPath = fsFolder + "\" + fsFileName
    fs.copyfile "C:\Cutbank - VB6\data.mdb", fsPath
End Sub
0
joyful88Author Commented:
It seems to crash on the fs.copyfile method. The paths and file names work fine. Even when i go:
    fs.copyfile "C:\Cutbank - VB6\data.mdb", fsFileName
I still get the same error for the Floppy, but with the cd-r drive it doesn't save.
is there another way of copying a file without using copyfile method for floppies and cds?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

joyful88Author Commented:
It seems to crash on the fs.copyfile method. The paths and file names work fine. Even when i go:
    fs.copyfile "C:\Cutbank - VB6\data.mdb", fsFileName
I still get the same error for the Floppy, but with the cd-r drive it doesn't save.
is there another way of copying a file without using copyfile method for floppies and cds?
0
bhagyeshtCommented:
oops sorry I forgot on

error resume next

statement


Private Sub mnuBackup_Click()
   error resume next
   Dim fs As Object
   Dim varFileName, fsFolder, fsPath, fsFileName As String
   
   comDlgBackup.ShowSave
   varFileName = comDlgBackup.FileName
   Set fs = CreateObject("Scripting.FileSystemObject")
NoDisk:    
   if err.number<>0 then
       err.clear
       Msgbox "Insert Disk in medium"
   end if
   fsFolder = fs.getparentfoldername(varFileName)
   fsFileName = fs.getfilename(varFileName)
   on error goto NoDisk
   If fsFolder = "a:\" Or fsFolder = "e:\" Then fsPath = fsFolder + fsFileName Else fsPath = fsFolder + "\" + fsFileName
   fs.copyfile "C:\Cutbank - VB6\data.mdb", fsPath
   on error goto 0
End Sub
0
mlmccCommented:
Are you running something like DirectCD which allows you to treat the CD as if it were a floppy?  Generally you cannot copy files to a CD without using the CD writer software.

Perhaps you could copy the files to your hard drive then offline copy them to a removeable media.

mlmcc
0
bhagyeshtCommented:
yes mlmcc is right, You need the direct cd to be active. and the Direct cd should have made the cd medium as ready. if an error occurs ask the user to make sure that the CD is writable
0
joyful88Author Commented:
No, i am not running a directCD, i just want the files to copy over onto the Save/CD drive window, then do the writting later on outside of the program.

i think i know why my floppy doesn't work ... my previous codes worked just fine, the file i was copying to the floppy was too big to fit! so that's one problem solved ... now how can i make saving to the CD work? any suggestions welcome!
0
mlmccCommented:
Not sure I understand the Save/CD drive window.

Without using something like Direct CD you must use a program like Easy CD Creator.  A CD is not  directly addressable like a floppy.

mlmcc
0
bhagyeshtCommented:
use directCD it will treat ur cd as a floppy/hard disk drive
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
joyful88Author Commented:
where can i get directCD?
0
mlmccCommented:
DirectCD came with my CD-RW as part of the software supplied.

It is part of EasyCreator CD by Roxio

www.roxio.com

mlmcc
0
bhagyeshtCommented:
I had got it with adaptec software which came with my cd writer
0
joyful88Author Commented:
so how can i incorporate this with my application? do i call somehow call it up? does Visual Basic 6 support it?
0
mlmccCommented:
It runs on its own in the background.  You can load it when you boot the system or you can start it from the start menu.  Once it is running the CD can be treated like a floppy by any program.

mlmcc
0
bhagyeshtCommented:
its a driver the CD drive will be treated as a floppy drive for the OS so definately for VB too (as long as there is a valid CD in the drive.) just use it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.