Solved

Format a Hard disk Partition with c#

Posted on 2003-11-16
4
6,099 Views
Last Modified: 2012-05-04
hi i want to develope a program .to do do some sort of formating partitions.and so on.is it possible to do in c#,and if yes could anyone supplay me with more info.cause may i will develop a program like partition magic with c#
0
Comment
Question by:hema_jone_mickey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9762277
Check this out. It's Visual Basic but you can probably convert it to C#.
0
 
LVL 6

Accepted Solution

by:
martinv earned 30 total points
ID: 9944470
Try using SHFormatDrive API function
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shformatdrive.asp)

// C#
[DllImport("shell32.dll",
    EntryPoint="SHFormatDrive",
    CharSet=CharSet.Unicode)]
public static extern Int64
    SHFormatDrive(IntPtr hwnd,
    int drive, int fmtID,
    int options);


// C#

private void CallSHFormatDrive_Click(object sender,
    System.EventArgs e)
{
    if (NativeMethodsOrdinal.SHFormatDrive(this.Handle,
        2, SharedNativeMethods.SHFMT_ID_DEFAULT,
        (int)SharedNativeMethods.
            ShellFormatOptions.SHFMT_OPT_FULL)
        == (long)SharedNativeMethods.
            ShellFormatReturnCodes.SHFMT_CANCEL)
        MessageBox.Show("Format Canceled");
}

Code taken from http://www.duncanmackenzie.net/writing/SettlementAPIs.htm
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question