By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,863 Members | 853 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,863 IT Pros & Developers. It's quick & easy.

How to copy a file from within an access app to a CD drive

P: 167
I am using 'fs.copyfolder' to copy folder data to a network location, this is working fine. Now I need to write this folder and contents out to a cd drive instead of to the network. I have tried using fs.copyfile "c:\fileABC" to "d::\fileABC" (D is my drive for the cd writer). Has anybody written/copied files like this out of an access application?
Feb 26 '09 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 2.5K+
P: 2,545
Hi. Is there some reason why you cannot use Copyfolder once again?

I use the filesystem object to copy a database file from a live location to an off-line location on a different server. The bare code for doing so (without the setting of the from and to strings and all the user messages etc concerned) is extracted and listed below:

Expand|Select|Wrap|Line Numbers
  1. Dim fso As Object, f2 As Object
  2.     Dim strCopyFrom As String, strCopyTo As String
  3.     Set fso = CreateObject("Scripting.FileSystemObject")
  4.     ..<from and to strings need to be passed as parameters or otherwise set before use>..
  5.     Set f2 = fso.GetFile(strCopyFrom)
  6.     f2.Copy (strCopyTo)
  7.     Set fso = nothing
  8.     Set f2 = nothing
However, writing to a CD drive may be problematic, as the files may well need to be cached until you write them to the drive under manual control. It may well be better to write the folder to a temporary folder area and then transfer them to CD when your drive writing software is available under manual control...

Feb 26 '09 #2

P: 167
Thanks for your reply. I am currently using the FSO method to copy the file from the C drive to a network drive. This works fine. The problem is that my users want me to copy the file to a cd disk 'automatically' in the code so they do not have to do this manally.
I substitued my 'to' location with the drive letter 'D:" (is the cd drive on my machine). I thought when the code was executed it would prompt me to put in a cd once it hit the copy code for the drive 'D', however, that is not what happens. Code just gets hung and does nothing.
Feb 27 '09 #3

Expert Mod 2.5K+
P: 2,545
Hi. I haven't tried writing to a CD drive myself, so all I can do is to suggest that this is not likely to work as you expect. Writing to a rewritable CD or to a write-once CD-ROM does not work the same way as a hard disk or a flash drive, and I really doubt the the FSO routines were built for such drives. Hence why I reckoned that writing to such disks would be a manual process, and I advocated writing to a temporary folder instead (or a different medium).

At the very least, you are going to have to detect the state of the drive itself before you attempt to write to it, then figure out how to write the cached set of files to the drive. This is likely to involve calls to Windows API functions in one form or another, well beyond the use of the file system object itself I reckon.

Feb 27 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.