473,509 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

code to burn and read files from cd rom

3 New Member
can anyone suggest me how can i burn and read data from cd rom in c# language.???
Jan 9 '13 #1
5 2862
PsychoCoder
465 Recognized Expert Moderator Contributor
Bytes.com isn't a code or homework service, we're a community of like minded people who come together to help those who are willing to help themselves.

Show us what you've tried and we will do everything we can to nudge you in the right direction but we will not just do the work for you.
Jan 9 '13 #2
pajju1992
3 New Member
this is the code what i have now......

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. using System.IO;
  6. using System.Runtime.InteropServices;
  7. using System.Text;
  8.  
  9. class CSburnD
  10. {
  11.     [DllImport("shfolder.dll")]
  12.     static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder,
  13.                                       IntPtr hToken, int dwFlags,
  14.                                       StringBuilder pszPath);
  15.  
  16.     const int CSIDL_CDBURN_AREA = 0x3B;
  17.     const int SHGFP_TYPE_CURRENT = 0;
  18.  
  19.     public static void Main(string[] args)
  20.     {
  21.         StringBuilder szPath = new StringBuilder(1024);
  22.         if (SHGetFolderPath((IntPtr)0, CSIDL_CDBURN_AREA, (IntPtr)0,
  23.             SHGFP_TYPE_CURRENT, szPath) != 0)
  24.             Console.WriteLine("SHGetFolderPath() failure");
  25.         else
  26.             Console.WriteLine("SHGetFolderPath return value = " + szPath);
  27.         Console.Read();
  28.  
  29.         Guid CLSID_CDBurn = new Guid("fbeb8a05-beee-4442-804e-409d6c4515e9");
  30.  
  31.         Type t = Type.GetTypeFromCLSID(CLSID_CDBurn);
  32.         if (t == null)
  33.         {
  34.             Console.WriteLine("ICDBurn not supported by OS");
  35.             Console.Read();
  36.             return;
  37.         }
  38.  
  39.         ICDBurn iface = (ICDBurn)Activator.CreateInstance(t);
  40.         if (iface == null)
  41.         {
  42.             Console.WriteLine("Unable to obtain interface");
  43.             Console.Read();
  44.             return;
  45.         }
  46.  
  47.         bool hasRecorder = false;
  48.         iface.HasRecordableDrive(ref hasRecorder);
  49.         Console.WriteLine("HasRecordableDrive return value = " + hasRecorder);
  50.         Console.Read();
  51.         if (hasRecorder)
  52.         {
  53.             StringBuilder driveLetter = new StringBuilder(4);
  54.             iface.GetRecorderDriveLetter(driveLetter, 4);
  55.             Console.WriteLine("GetRecorderDriveLetter return value = " +
  56.                               driveLetter);
  57.             Console.Read();
  58.             iface.Burn((IntPtr)0);
  59.         }
  60.     }
  61. }
  62.  
  63. [ComImport]
  64. [Guid("3d73a659-e5d0-4d42-afc0-5121ba425c8d")]
  65. [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  66. public interface ICDBurn
  67. {
  68.     void GetRecorderDriveLetter([MarshalAs(UnmanagedType.LPWStr)]
  69.                                 StringBuilder pszDrive, uint cch);
  70.     void Burn(IntPtr hwnd);
  71.     void HasRecordableDrive(ref bool HasRecorder);
  72.  
  73. }
Jan 9 '13 #3
Rabbit
12,516 Recognized Expert Moderator MVP
And is there something wrong with the code? You haven't told us anything about it.
Jan 9 '13 #4
pajju1992
3 New Member
No there is nothing wrong with the above code... it works properly..
Jan 16 '13 #5
Rabbit
12,516 Recognized Expert Moderator MVP
So then this thread is resolved and you need no further assistance?
Jan 16 '13 #6

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

Similar topics

1
1530
by: S Austin | last post by:
Discovered recently (duh) that putting inline code in .h files (e.g. in class definitions) is not a good idea when building DLLs and the applications that use those DLLs. The reason being, of...
2
4850
by: none | last post by:
Hi, Any one know of some code to read cobol data files.... thanks timb
3
5037
by: Kay | last post by:
IIS cannot read files in a directory reporting that : Microsoft VBScript runtime (0x800A01B6) Object doesn't support this property or method: 'Fso.GetFolder' This has to do with...
0
1247
by: John E Katich | last post by:
When attempt to use the Event Wizard I get the following error message: "Add/Remove of the function impossible, because the parent class code is read only" The Project was convert from VC 6.0....
2
2170
by: Argirop | last post by:
I started recently with asp.net 2.0 and I am currently trying to generate the mysite.dll by compiling the corresponding code behind .cs files. I am using the csc tool that displays one CS0103...
14
3573
by: IVETH | last post by:
Hi Can anyone provide an example of how to read files in java and upload this information to the database ? Thanks
4
1709
by: smartjoe85 | last post by:
can anyone give me a program to read files from my harddisk from dos environment
11
2109
by: alivip | last post by:
how to ingrate my code to read text in in parent folder contain sub folders and files for example folder name is cars and sub file is Toyota,Honda and BMW and Toyota contain file name Camry and...
1
2428
by: pritdongare | last post by:
hiiiii, pritam here. i m doing xml parsing,,in dis i hav to take xml files one by one from folder and then parse them,,In this i won to know how to read files from folder.plz try to reply fast.
0
7135
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7410
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.