views:

127

answers:

5

Possible Duplicate : Write to CD from .net

I have a data file in f:\ drive named 'cd.txt'. I want to write this file to a CD i.e E:\.

String source ="F:\\cd.txt";
String destination="E:\\cd.txt";

File.copy(sorce,destination);

The above line is throwing exception saying "Access to the path 'E:\cd.txt' is denied".

What is the solution for this .Please help.

+1  A: 

I don't think that's so easily feasible, Windows explorer give the impression doing a file copy is enough but that not the case.

I think you might take a look at XPBurn component.

RageZ
+3  A: 

Is the .NET/C#? You can use ICDBurn to copy files to a disc. See this answer:

http://stackoverflow.com/questions/799867/write-to-a-cd-from-net

pygorex1
A: 

You cant just copy files to a disc drive. Writing files to a CD-R is a complicated process.

I have heard of a C# .NET component called XPBurn. I have not used it, but it looks like it'll do what you need using the IMAPI Interfaces.

Arriu
A: 

Yes, but it's technically Windows API:

Dhawan the One

John Weldon
why is that exception thrown? What is the solution?
Nitin
You're trying to treat the drive as a normal read-write drive... I suspect you have to 'prep' the drive before you can do that.
John Weldon
A: 

IMAPI is only for C++, is there a good wrapper for C#? o maybe a library? i used the project wrapper from the codeproject page.. i haven't test it, all i did was exclude the Interop folder and moved it to another project to try and build the winform in WPF.. therefore i excluded the Interop to a single class project for a DLL... will test it this week..

Dabiddo