我有这个用于创建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);
}
Run Code Online (Sandbox Code Playgroud)
在compressor.CompressDirectory完成创建ZIP文件之后,我想向用户显示ZIP文件,以便他们可以轻松地复制它或只看到它在哪个目录中创建.
我怎样才能做到这一点?
Process.Start("explorer", String.Format("/select,{0}", zipFileName));
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
68 次 |
| 最近记录: |