Solved

writing to floppy and CD-R drives

Posted on 2003-11-15
18
405 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
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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
A short article about problems I had with the new location API and permissions in Marshmallow
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

863 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

20 Experts available now in Live!

Get 1:1 Help Now