views:

39

answers:

1

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.

A: 

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:

[string filePath = @""C:\Windows\FolderName\FileName.txt"";]

If this still doesn't work then could you please post how you are inputting this?

VoodooChild
this is how it appears in quickwatch.completeFilePath=D:\test\NUnit_b2e5d79c-7512-40ad-bcb6-f0b16fe9f7b8.msi . This file exists in this location.
Rohit
@Rohit: It seems to me that my posted answer is correct. The "FileVersionInfo.GetVersionInfo" is excepting a string param. quickWatch.completeFilePath is a string but you need to modify this for the special characters ('\') probably in another temp string and pass the temp string in to the "FileVersionInfo.GetVersionInfo" method.
VoodooChild