Solved

writing to floppy and CD-R drives

Posted on 2003-11-15
18
428 Views
Last Modified: 2012-06-27
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!
0
Comment
Question by:joyful88
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 5
18 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 9757252
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
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9761686
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
 

Author Comment

by:joyful88
ID: 9768124
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:joyful88
ID: 9768125
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
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9768994
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 9769122
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
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9769157
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
 

Author Comment

by:joyful88
ID: 9773448
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 9775696
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
 
LVL 9

Accepted Solution

by:
bhagyesht earned 100 total points
ID: 9776673
use directCD it will treat ur cd as a floppy/hard disk drive
0
 

Author Comment

by:joyful88
ID: 9820396
where can i get directCD?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9822205
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
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9822500
I had got it with adaptec software which came with my cd writer
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9822502
0
 

Author Comment

by:joyful88
ID: 9840576
so how can i incorporate this with my application? do i call somehow call it up? does Visual Basic 6 support it?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9842750
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
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9848088
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is about my first experience with programming Arduino.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question