473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Getting correct version using FileVersionInfo

Jim
Hi. I would like to validate the version string that I
get from FileVersionInfo. Is there a way via the object
model to do this?

I am currently doing this:
FileVersionInfo fileVersionInfo =
FileVersionInfo.GetVersionInfo(filePath);

string fileVersion = fileVersionInfo.FileVersion;
Sometimes though, I get versions that look like "5.2.02.2
WestNileBuild" or others that look like "5,2,3,0"

Is there a way to format whatever result I get, to look
like one of the following formats:

1
1.1
1.1.1
1.1.1.1
Thanks

Jim
Nov 13 '05 #1
1 6186
Jim
I am using this method to determine if it is a valid
version or not. Is there a cleaner way?

private bool IsVersion(ref string fileVersion)
{
// For cases of 5,5,2,2
fileVersion = fileVersion.Trim().Replace
(",", ".");
fileVersion = fileVersion.Replace(" ", "");
string[] versionParts = fileVersion.Split('.');
bool result = true;

foreach (string versionPart in versionParts)
{
try
{
int iVersionPart = Convert.ToInt32
(versionPart);
}
catch (Exception)
{
result = false;
break;
}
}
return result;
}

-----Original Message-----
Hi. I would like to validate the version string that I
get from FileVersionInfo. Is there a way via the object
model to do this?

I am currently doing this:
FileVersionInfo fileVersionInfo =
FileVersionInfo.GetVersionInfo(filePath);

string fileVersion = fileVersionInfo.FileVersion;
Sometimes though, I get versions that look like "5.2.02.2WestNileBuild" or others that look like "5,2,3,0"

Is there a way to format whatever result I get, to look
like one of the following formats:

1
1.1
1.1.1
1.1.1.1
Thanks

Jim
.

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Frank T. Clark | last post by:
I am having trouble trying to retrieve the version resources of the executing assembly at runtime. I want to retrieve AssemblyTitle, AssemblyDescription, AssemblyCompany, AssemblyProduct, and...
2
by: jwexqm | last post by:
I'm using a COM DLL from a C# application via an interop wrapper generated by 'tlbimp.exe'. That all works fine, I can fire off methods and things happen as they should. My issue is that I want...
2
by: kris | last post by:
Hello, We're porting some old code to our new C# .NET project and are having trouble getting the file version of a non-.NET EXE file using C# .NET code. In our old code, we were using the...
5
by: Paul Horn | last post by:
Hi I need some help here. I would appreciate it if any one can help me. My 2 questions is this: 1. How do you get a list of installed applications on Windows? 2. How do I get a program's...
2
by: Robert | last post by:
I have an application migrated from 1.1 to 2.0 via VS2005. Under 1.1 I could do the following to return the version information (as found in the assemblyinfo.vb file) GetVersion =...
5
by: Brian Henry | last post by:
If you want to read in the description/version/copyright of a file (any not necessarly a .NET one) how would you do this? I just want to list all the files in a directory and their version numbers...
0
by: Grant_Sutty | last post by:
Hi The only file information I need to access for a bunch of files (dlls & exe) on several remote servers is "file version number". Using the code below, I appear to be able to access all...
4
by: =?Utf-8?B?U2hhcm9u?= | last post by:
How can I read the version of an existing file? The file I checking is a COM dll file. ------- Thanks Sharon
2
by: =?Utf-8?B?Unlhbg==?= | last post by:
I am using vb.net to launch an external application (.exe); how do I capture this external applications's version number in my vb.net app?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.