在c#中获取补丁文件的版本信息
我正在使用文件上传控件将 .msi 文件上传到中央位置。现在我需要获取该文件的版本信息。我正在使用以下代码。
FileVersionInfo patchFile = FileVersionInfo.GetVersionInfo(completeFilePath)
CompleteFilePath 是上传文件的完整路径。此代码中断并抛出文件未找到异常。但是,如果我在物理目录中查找,文件存在于那里。
我是否遗漏了某些内容,或者我是否必须再次将此上传的文件下载到某个临时位置,然后从此文件中提取版本信息。
我的第二个选择是在上传文件之前获取版本信息。在这种情况下,我无法获取此补丁文件的完整路径,因为文件上传控件仅提供文件名而不是完整位置。
请建议如何进行。
I am uploading a .msi file using fileupload control to a central location. Now i need to get version info of this file. I am using the following code.
FileVersionInfo patchFile = FileVersionInfo.GetVersionInfo(completeFilePath)
completeFilePath is the full path of the uploaded file. This code breaks and throws file not found exception.however, if i look down in the physical directory,file exists there.
Am i missing something or will i have to download this uploaded file again to some temp location and then extract version info from this file.
Second option i had was to get version info before uploading the file. In this case i am not able to get complete path of this patch file as fileupload control just gives the fileName and not the complete location.
Please suggest how to proceed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题在于如何定义“completeFilePath”
请记住,如果completeFilePath 是非文字字符串,那么您必须转义特殊字符。
例如:
[string filePath = "C:\\Windows\\FolderName\\FileName.txt";]
(注意转义字符 ()
另一种选择是使用文字字符串,它使您能够使用特殊字符而不必使用转义字符。一个示例是:
如果这仍然不起作用,那么您可以发布您的情况吗输入这个?
I think the problem is in how to define "completeFilePath"
Remember that if the completeFilePath is a non-literal string then you must escape the special characters.
For example:
[string filePath = "C:\\Windows\\FolderName\\FileName.txt";]
(notice the escape character ()
Another option is to use the literal string which enables you to use the special characters without having to use the escape character. An example is:
If this still doesn't work then could you please post how you are inputting this?