Solved

writing to floppy and CD-R drives

Posted on 2003-11-15
18
394 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
  • 7
  • 5
  • 5
18 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:joyful88
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
Comment Utility
use directCD it will treat ur cd as a floppy/hard disk drive
0
 

Author Comment

by:joyful88
Comment Utility
where can i get directCD?
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
Comment Utility
I had got it with adaptec software which came with my cd writer
0
 
LVL 9

Expert Comment

by:bhagyesht
Comment Utility
0
 

Author Comment

by:joyful88
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now