Solved

Format a Hard disk Partition with c#

Posted on 2003-11-16
4
6,028 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

820 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