我的自定义安装程序出现问题 [英] Problems With My Custom Installer

查看:130
本文介绍了我的自定义安装程序出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前创建了一个自定义安装程序,它运行正常,但我遇到了一些问题。



与软件包安装程序不同,它的速度要慢得多在安装。



这是安装程序的工作方式:



1.删除所有临时文件如果以前安装了安装程序,请在计算机上安装



2.然后安装程序将.zip文件从资源文件夹移动到用户计算机



3.之后它会提取.zip(因此我使用DotNetZip库)



4.然后移动文件它被提取到正确的导演(y)(ies)



5. ...最后它只是从计算机中删除.zip和解压缩的文件夹/>


我在工作之前使用安装程序大约需要5-7秒。



他们将相同的文件移动到我的,但是我定制的安装程序在40左右完成了相同的工作在我的电脑上大概等等......对于用户来说,它可能会持续3到4分钟。



我不会对这个事实感到恼火,如果不是一个因素...程序处理的文件只值40 - 50MB,这基本上没什么。



...所以我在想,他们是怎么做到的?也许我有办法避免移动.zip并解压缩它。



有没有办法可以将已提取的文件夹放入我的Resources文件夹或将它放在项目中并移动到计算机上。



如果您有任何建议,我会非常乐意考虑它们!



代码段:



删除临时文件:



< pre lang =vb> 尝试
Dim peth 作为 字符串 =(DirectoryToInstall& \Svatekl2.zip
如果 File.Exists(peth)= True 然后
FileSystem.Kill(peth)
结束 如果

Catch
结束 尝试

尝试

如果 My.Computer.FileSystem.DirectoryExists(DirectoryToInstall& \ Svatekl3)= True 然后
My.Computer.FileSystem.DeleteDirectory(DirectoryToInstall& \Svatekl3,FileIO.UIOption.OnlyErrorDialogs,FileIO.RecycleOption.SendToRecycleBin,FileIO.UICancelOption.ThrowException)
End 如果
Catch
End 尝试





移动zip文件...

 私人  Sub  MoveZip()
IO.File.WriteAllBytes(DirectoryToInstall& \ Svatekl2.zip,My.Resou rces.Svatekl2)
结束 Sub





提取......

 Private Sub MyExtract()

Dim ZipToUnpack As String =(DirectoryToInstall& ; \ Svatekl2.zip)
Dim UnpackDirectoryToInstall As String =(DirectoryToInstall&\ Svatekl3)
使用zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
Dim e As ZipEntry
For each e In zip1
e.Extract(UnpackDirectoryToInstall,ExtractExistingFileAction.OverwriteSilently)
Next
End using
End Sub





要移动文件我使用TON代码......我不会在这里发布所有内容,我只会举例说明其中一个看起来如何! (它们看起来非常相似)



 如果 SafeShot.Checked =  True  然后 
My.Computer.FileSystem.MoveDirectory(DirectoryToInstall& \Svatekl3 \Svatekl2 \ SafeShot \ Allies and Dead \scripts,(DirectoryToInstall)& \ res_mods \0.9.7 \ scripts
结束 如果





最后它再次运行DeleteTemp(),这也是它在安装过程中所做的第一件事。

解决方案

< blockquote>根据你描述的内容,没有看到任何代码,我怀疑你的问题是删除临时文件。听起来你正在删除整个临时目录的内容,对于一些用户来说,这可能是数十亿字节的数据。我建议你在临时文件夹中创建一个目录,GUID作为文件夹名称。让您的安装运行,然后删除您创建的文件夹。让用户处理清理他们的临时目录。


I created a custom installer a bit ago and it works fine but I am having a few issues with it.

Unlike a package installer it is by far slower at installing.

This is how the installer works:

1. It deletes all the temporary files on the computer in case the installer was previously installed

2. Then the installers moves a .zip file to the users computer from the resources folder

3. After which it extracts the .zip (I use DotNetZip library for thus)

4. Then it moves the files it extracted to the correct director(y)(ies)

5. ...and finally it just deletes the .zip and the extracted folder off the computer

I have used installers before their job in around 5 - 7 seconds.

They move the same files as mine, but my installer that was custom made by me does the same exact job in around 40 seconds or so on my computer... For the users, it could last for up to 3 - 4 minutes.

I wouldn't be so annoyed by this fact, if not one factor... The files that the program deals with is only worth 40 - 50MB which is basically nothing.

...So I was thinking, how do they do that? Maybe there is a way for me to avoid moving the .zip and unpacking it.

Is there a way I could possibly place the already extracted folder into my Resources folder or place it inside the project and move it to the computer.

If you have an suggestions, I would be more than happy to consider them!

Code snippets:

Deleting Temp Files:

Try
           Dim peth As String = (DirectoryToInstall & "\Svatekl2.zip")
           If File.Exists(peth) = True Then
               FileSystem.Kill(peth)
           End If

       Catch
       End Try

       Try

           If My.Computer.FileSystem.DirectoryExists(DirectoryToInstall & "\Svatekl3") = True Then
               My.Computer.FileSystem.DeleteDirectory(DirectoryToInstall & "\Svatekl3", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin, FileIO.UICancelOption.ThrowException)
           End If
       Catch
       End Try



Moving the zip file...

Private Sub MoveZip()
        IO.File.WriteAllBytes(DirectoryToInstall & "\Svatekl2.zip", My.Resources.Svatekl2)
    End Sub



Extracting...

Private Sub MyExtract()

        Dim ZipToUnpack As String = (DirectoryToInstall & "\Svatekl2.zip")
        Dim UnpackDirectoryToInstall As String = (DirectoryToInstall & "\Svatekl3")
        Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
            Dim e As ZipEntry
            For Each e In zip1
                e.Extract(UnpackDirectoryToInstall, ExtractExistingFileAction.OverwriteSilently)
            Next
        End Using
    End Sub



To move the files I use a TON of code... I will not post it all here, I will just give you an example of how one of them looks! (They all look really similar)

If SafeShot.Checked = True Then
            My.Computer.FileSystem.MoveDirectory(DirectoryToInstall & "\Svatekl3\Svatekl2\SafeShot\Allies and Dead\scripts", (DirectoryToInstall) & "\res_mods\0.9.7\scripts", True)
        End If



Lastly it runs the DeleteTemp() again which is the first thing it does in the installation process as well.

解决方案

Based on what you described and without seeing any code, I suspect your issue is the deleting of temporary files. It sounds like you are deleting the contents of the entire temporary directory and for some users, this could be tens of gigabytes of data. I suggest you create a directory in the temporary folder with a GUID as the folder name. Let your install run, then remove the folder you created. Let the user handle cleaning up their temporary directory.


这篇关于我的自定义安装程序出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆