使用安装向导安装隐藏文件

时间:2019-02-02 13:46:57

标签: c# wpf installation

我正在开发具有许可证管理的wpf c#应用程序。 当客户端获得许可证时,应用程序允许他使用“ OpenFileDialog”将其导入,该许可证文件是XML(License.xml)。导入此文件时,它将在“ ExecutablePath”中复制

class PersonForm(forms.ModelForm):
    class Meta:
        model = Person
        fields = ["is_adult"]
        widgets = {
            'is_adult': forms.Select(attrs={'class': 'form-control'}),
        }
        labels= {
            'is_adult': 'Is an adult?',
        }

应用程序重新启动并识别出来。

            openFileDialog.ShowDialog();
        string filePath = openFileDialog.FileName.Trim();
        if (filePath != string.Empty)
        {
            string filename = Path.GetFileName(filePath);
            if (filename.ToUpper() == "LICENCE.XML")
            {
                if (!ReadLicense(filePath))
                {
                    return false;
                }
                else
                {
                    string destPath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
                    File.Copy(filePath, Path.Combine(destPath, filename), true);
                    return true;
                }
            }
            else
            {
                return false;
            }
        }

在调试模式下,此文件已正确复制,并且在“ C:\ Program Files(x86)\ AppName”文件夹中可见。如果我将发布文件夹复制到“ C:\ Program Files(x86)..”中,它也可以正常工作。

应用程序是由安装向导安装的,当应用程序启动时,它会申领许可证,并且在导入后,它会识别并启动,一切正常。 我在问的是许可证文件(License.xml)在安装文件夹('C:\ Program Files(x86)\ AppName')中不可见,但可以正确找到它。我把嗅探器这样看:

    if (GetLicenceFile())
{
    App.Current.Shutdown();
    System.Windows.Forms.Application.Restart();
}

如果我从“控制面板”中卸载了该应用程序,则“ C:\ Program Files(x86)\ AppName”会完全消失,但是在下一次安装时,该应用程序将通过查找许可证启动,而该文件应该位于卸载时应该删除“ C:\ Program Files(x86)\ AppName”。

我们可能认为'License.xml'正在复制到其他地方。

我不明白为什么我无法使用“向导安装”找到该文件,即使使用隐藏文件选项,即使Windows资源管理器搜索也找不到该文件。

一个主意?

0 个答案:

没有答案
相关问题