gpt4 book ai didi

c# - 向用户显示已创建文件的最佳方式是什么?

转载 作者:行者123 更新时间:2023-11-30 19:42:07 24 4
gpt4 key购买 nike

我有创建 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.

关于c# - 向用户显示已创建文件的最佳方式是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18048271/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com