Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing Data on CD

Status
Not open for further replies.

saimagulse

Programmer
Aug 5, 2006
9
0
0
PK
Hi
I want to write data on CD through VB.
For example if i have a back up folder and i want to write a program in VB so that user press just one button and this data will be write on cd. How it would be done?
Please help me as soon as possible
 
Pretty much the same way that you would write or copy a file to anywhere else. For example
Code:
FSO.CopyFile "C:\myDir\myFile.txt", "D:\myFile.txt"
Will copy a file from the C: drive to the D: drive (FSO is a FileSystemObject in this example.)

OR
Code:
Open "D:\NewFile.Txt" For OutPut As #1
For n = 0 To UBound(myArray)
   Print #1, myArray(n)
Next
Close #1
Will create a file on the D: drive and write data to it.

Note that you should probably have code to test if there is a CD in the drive and that it is not Read-Only. You might do something like
Code:
Public Sub BadDriveReason(Folder As String) As String
If Len(Folder) = 0 Then
    BadDriveReason = "Folder is NOT Defined"
Else
    If Not FSO.DriveExists(Left$(Folder, 2)) Then
        BadDriveReason = "Drive does not exist."
    ElseIf Not FSO.Drives(Left$(Folder, 1)).IsReady Then
        BadDriveReason = "Drive is NOT Ready."
    ElseIf Not FSO.FolderExists(Folder) Then
        BadDriveReason = "Directory does NOT Exist."
    ElseIf FSO.GetFolder(Folder).Attributes And 1 Then
        BadDriveReason = "Folder is Read-Only"
    End If
End If
End Function
 
Hi Golom
Thanks for your response but solution you have provided can not resolve the problem. Method you have described is used to copy on hard disk drives or on floppy disks but can not be appplied on CD drive. As you have provided i check it with my CD writer by inserting a writeable cd in it but when i run the command it returns me error "Permission denied" however i can write same file on it by copy and paste. Logically it seems that it should also work correctly on cd drive but it is not so why i dnt know.
I have also seen it in VBAcclerator forum which gives a no of dlls for doing it but i can not understand that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top