?
Solved

Format a Hard disk Partition with c#

Posted on 2003-11-16
4
Medium Priority
?
6,161 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 90 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

752 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