2013-08-04 3 views
2

내가 ZIP 파일 생성이 코드를 가지고 : compressor.CompressDirectory이 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); 
} 

오른쪽, 나는 그들이 그것을 복사하거나 볼을 쉽게 할 수 있도록 사용자에게 ZIP 파일을 표시하려는 디렉토리

어떻게하면됩니까?

+0

'파일 이름과 Process.Start'는 – Sayse

+0

Sayse를 작동해야 난이 시도 : Process.Start (t); zip 파일 내용 만 보여줍니다. 내가 원하는 건 아니야. – DanielVest

+0

오, 그래서 당신이 디렉토리를 열고 파일을 보여주고 싶어? – Sayse

답변

8
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. 
0

"explorer.exe"프로세스를 실행하여 디렉터리를 명령 줄 인수로 제공하십시오. 그러나 휴대용 방식으로이를 수행하는 방법을 잘 모르겠으므로 Mono에서도 작동합니다.

0

포함하는 폴더를 열 것이다 방법의 마지막에 넣어 다음 행

Process.Start("explorer.exe", output); 
관련 문제