向用户显示创建的文件的最佳方式是什么
本文关键字:最佳 方式 是什么 文件 显示 创建 用户 | 更新日期: 2023-09-27 18:26:16
我有以下代码用于创建ZIP文件:
void Compress(string contentDirectory, string zippedFileDirectory)
{
… // locate 7z.dll and invoke SevenZipExtractor.SetLibraryPath
SevenZipCompressor compressor = new SevenZipCompressor()
{
ArchiveFormat = OutArchiveFormat.Zip,
CompressionMode = CompressionMode.Create,
TempFolderPath = Path.GetTempPath()
};
string source = contentDirectory;
string output = zippedFileDirectory;
string zipFileName = "Diagnosis_Files.zip";
string t = Path.Combine(output, zipFileName);
compressor.CompressDirectory(source, t);
}
在compressor.CompressDirectory
完成创建ZIP文件后,我想向用户显示ZIP文件,这样他们就可以轻松地复制它,或者只查看它是在哪个目录中创建的。
我该怎么做?
Process.Start("explorer", String.Format("/select,{0}", zipFileName));
Explorer [/n] [/e] [(,)/root,<object>] [/select,<object>]
/n Opens a new single-pane window for the default
selection. This is usually the root of the drive Windows
is installed on. If the window is already open, a
duplicate opens.
/e Opens Windows Explorer in its default view.
/root,<object> Opens a window view of the specified object.
/select,<object> Opens a window view with the specified folder, file or
application selected.
Examples:
Example 1: Explorer /select,C:'TestDir'TestApp.exe
Opens a window view with TestApp selected.
Example 2: Explorer /e,/root,C:'TestDir'TestApp.exe
This opens Explorer with C: expanded and TestApp selected.
Example 3: Explorer /root,''TestSvr'TestShare
Opens a window view of the specified share.
Example 4: Explorer /root,''TestSvr'TestShare,select,TestApp.exe
Opens a window view of the specified share with TestApp selected.
运行"explorer.exe"进程,提供目录作为其命令行参数。但是,我不知道如何以可移植的方式做到这一点,所以它也可以在Mono上工作。
方法末尾的以下行将打开包含文件夹:
Process.Start("explorer.exe", output);