惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
The Register - Security
The Register - Security
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
GbyAI
GbyAI
Recent Commits to openclaw:main
Recent Commits to openclaw:main
博客园_首页
D
Docker
S
Security @ Cisco Blogs
K
Kaspersky official blog
爱范儿
爱范儿
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
V
V2EX
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Troy Hunt's Blog
Cloudbric
Cloudbric
博客园 - 三生石上(FineUI控件)
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The Hacker News
The Hacker News
美团技术团队
S
SegmentFault 最新的问题
L
Lohrmann on Cybersecurity
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
宝玉的分享
宝玉的分享
The Last Watchdog
The Last Watchdog
Y
Y Combinator Blog
M
MIT News - Artificial intelligence
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Martin Fowler
Martin Fowler
Google Online Security Blog
Google Online Security Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tor Project blog
Vercel News
Vercel News
The Cloudflare Blog
G
Google Developers Blog
T
Threat Research - Cisco Blogs
AI
AI
Stack Overflow Blog
Stack Overflow Blog
I
InfoQ
Scott Helme
Scott Helme
S
Schneier on Security
大猫的无限游戏
大猫的无限游戏
The GitHub Blog
The GitHub Blog
S
Securelist
IT之家
IT之家
Microsoft Azure Blog
Microsoft Azure Blog

博客园 - 幸福的菜菜

windows下使用ACME申请SSL证书的办法 ElementPlus Radio 实现双击取消选择的效果 Windows10 LTSC版本 无法访问网络中部分的共享文件夹 SqlSugar : date绑定到XX失败,可以试着换一个类型,或者使用ORM自定义类型实现 VisualStudio Debug模式突然变慢 Visual Stadio 编译提示 The BaseOutputPath/OutputPath property is not set for project ... winform绘图与前端canvas绘图效率对比 node-sass编译不通过, 提示 “checking for Python executable "python2" in the PATH” c# async await的使用方式及为啥要用它 winform 实现对usb热拔插的监听 Laravel The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths Wampserver 配置端口可访问服务 git credential for windows 总是弹出的问题 如何用B表的数据,更新A表的值 WampServer部署https 服务的过程 PHP 命名空间冲突解决方式 Windows下 Docker 简单部署 Django应用 Winform 实现断点续传的思路及代码 WAMPServer ServerName has syntax error 的问题(阿里云服务器上)
C#实现后台格式化U盘的功能
幸福的菜菜 · 2018-08-29 · via 博客园 - 幸福的菜菜

检测U盘:

1                 DriveInfo[] s = DriveInfo.GetDrives();
2                 var result = string.Empty;
3                 foreach (DriveInfo i in s)
4                 {
5                     if (i.DriveType == DriveType.Removable)  //这里就是可移动的设备了
6                     {
7                           break;
8                     }
9                 }

格式化磁盘:

        /// <summary>
        /// 格式化磁盘
        /// </summary>
        /// <param name="DiskName">盘符名称:C:、D:、E:、F:</param>
        /// <returns></returns>
        public bool FormatDisk(string DiskName)
        {
            ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe");
            processStartInfo.RedirectStandardInput = true;
            processStartInfo.RedirectStandardOutput = true;
            processStartInfo.UseShellExecute = false;

            Process process = Process.Start(processStartInfo);

            if (process != null)
            {
                process.StandardInput.WriteLine($"FORMAT {DiskName} /y /FS:FAT32 /V:BMECG /Q");
                process.StandardInput.Close();

                string outputString = process.StandardOutput.ReadToEnd();
                if (outputString.Contains("已完成"))
                {
                    return true;
                }
            }
            return false;
        }

使用批处理 : 

FORMAT G: /Y /FS:NTFS /V:My_LABEL /Q

其中:

 G: is a drive letter for formating.  (需要格式化的磁盘)

/Y is used to force the format and bypass the confirmation (确认)

Do you really want to format the drive ?
Yes /No

 /FS is used to choose the file system either FAT32 Or NTFS  (设置格式)

/V is for labeling the drive after format  (格式化后的磁盘名)

/Q is used to perform quick format   (使用快速格式化)