473,667 Members | 2,737 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 2871
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
1537
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 course, is that the application gets its own copy of that code when it compiles and won't call the code in the DLL. Each compiled unit in the DLL also ends up with its own copy of the never-called code. Assuming the same build process for the DLL...
2
4868
by: none | last post by:
Hi, Any one know of some code to read cobol data files.... thanks timb
3
5042
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 Scripting.FileSystemObject. I make sure the scrrun.dll is properly registered with regsvr32. Still the problem persists. Previously I do not know what I did right once in permission setting and
0
1253
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. The files in question do not have the Read-Only Attribute on. Any Ideas?
2
2174
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 error message (The name '...' does not exist in current context) for every control id that I am using in the .ascx files ('...' is the id of the control). From one point of view this is logical since there are no anymore declarations for the page...
14
3587
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
1715
by: smartjoe85 | last post by:
can anyone give me a program to read files from my harddisk from dos environment
11
2122
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 file name corolla, file name Honda contain folder accord and BMW contain file name X5 Is there way to enter name of parent folder(cars) and search in all sub folder(Toyota,Honda and BMW) and files ? please help ASAP code is find most frequent...
1
2436
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
8458
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8790
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8565
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8650
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7391
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4202
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.