473,403 Members | 2,222 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,403 software developers and data experts.

File Version

I am trying to find a way to compare the version of the currently executing
assembly to the version of my latest upload so I can notify the user when a
newer version is available.

Is it possible to get the version information programmatically for an exe
file in some folder on my web site or alternatively to retrieve the version
information from information appearing on a web page on my web site?

Thanks,

Dennis
Nov 17 '05 #1
11 1793
Hi Dennis,
You can retrieve the Version object which contains the Major, Minor, Build,
and Revision properties of the assembly version.

Cheers,
Steve Goodyear

System.Version version =
System.Reflection.Assembly.GetExecutingAssembly(). GetName().Version;
MessageBox.Show(version.ToString());
Nov 17 '05 #2
Steve:

Thanks, but I knew that! What I had asked is how to retrieve the file
version of an exe from my server (the bundled install program) or how to
read some text from a page on my web site that contains version information
for the latest build.

Of course, I suppose I could embed the file version in a simple ascii text
file on my server and read that, but then that is one more thing that must
be remembered every time an upload is done.

Thanks,

Dennis
"Steve Goodyear" <St***********@discussions.microsoft.com> wrote in message
news:02**********************************@microsof t.com...
Hi Dennis,
You can retrieve the Version object which contains the Major, Minor,
Build,
and Revision properties of the assembly version.

Cheers,
Steve Goodyear

System.Version version =
System.Reflection.Assembly.GetExecutingAssembly(). GetName().Version;
MessageBox.Show(version.ToString());

Nov 17 '05 #3
Hi Dennis,

As for the
===================
how to read some text from a page on my web site that contains version
information for the latest build.
===================

do you mean that you'd like to provide a dynamic web page on your
webserver(IIS) which will return the components/application's update list
info? If so, I think it's a good idea and you can consider define your
update info as xml data so that the web page can return xml document to
client (contentType="text/xml").

Then, in the clientside, we can use the HttpWebRequest class (under
System.Net namespace) to retrieve the xml data from that web page). How do
you think of this? If you feel it's a possbile approach, I can paste some
sample code on using HttpWebRequest component to get response text from a
remote page.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 17 '05 #4
Steven:

My preference would be to get the version information for the setup.exe file
I upload to my web site for users to download. The setup.exe file is a
compressed setup file that contains all the dll and exe files
(assemblies)necessary for the program.

If that is not possible, then another method would need to be employed, such
as you mention. I have not worked with dynamic web pages, so I really can't
say if that will do or not. I will do some reading on that subject.

How about just reading a user variable property, a custom metadata element)
that I set for the downloads.htm web page of my site? Can I read that data
remotely? If so, it would be easy to set a value named Version and provide
its value every time I upload a new version.

Again, I would prefer to get that information directly from the uploaded
file it at all possible.

Thanks,

Dennis
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:uc**************@TK2MSFTNGXA01.phx.gbl...
Hi Dennis,

As for the
===================
how to read some text from a page on my web site that contains version
information for the latest build.
===================

do you mean that you'd like to provide a dynamic web page on your
webserver(IIS) which will return the components/application's update list
info? If so, I think it's a good idea and you can consider define your
update info as xml data so that the web page can return xml document to
client (contentType="text/xml").

Then, in the clientside, we can use the HttpWebRequest class (under
System.Net namespace) to retrieve the xml data from that web page). How do
you think of this? If you feel it's a possbile approach, I can paste some
sample code on using HttpWebRequest component to get response text from a
remote page.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 17 '05 #5
Hi Dennis,

Thanks for your reply. Actually the reason why I suggest use a page or
document to publish your application's update list is because the client
users are remote to the server you upload your setup package. So even if we
can easily get the version info from the setup package, we need to download
the setup package first( this will cause addiontal network transport. Also,
even we get the setup package download, we can't directly get info from the
package, we need to programmatically uncompressed the package and check
version from the file(such as asssemblies) in it. So I think using a text
format on the server and let the client applicaiton to request that text
file to get the latest update list info is the reasonable approach. In
.net, we can finish this through the following steps:

1. Put a xml static file on the server which contains the update list info
of your application/components

2. In client application, use the .net's HttpWebRequest component to get
the xml document on the remote server and load into a XmlDocument class

3. Use XPath to query the version information in the xmldocument and
determine whether to download update files or not.

How do you think of this? If you feel necessary I can post some sample code
snippet on this.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 17 '05 #6
Steven:

Yes, please show me some code snippets to extract version information from
an xml file.

Thanks,

Dennis
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:y%****************@TK2MSFTNGXA01.phx.gbl...
Hi Dennis,

Thanks for your reply. Actually the reason why I suggest use a page or
document to publish your application's update list is because the client
users are remote to the server you upload your setup package. So even if
we
can easily get the version info from the setup package, we need to
download
the setup package first( this will cause addiontal network transport.
Also,
even we get the setup package download, we can't directly get info from
the
package, we need to programmatically uncompressed the package and check
version from the file(such as asssemblies) in it. So I think using a text
format on the server and let the client applicaiton to request that text
file to get the latest update list info is the reasonable approach. In
net, we can finish this through the following steps:

1. Put a xml static file on the server which contains the update list info
of your application/components

2. In client application, use the .net's HttpWebRequest component to get
the xml document on the remote server and load into a XmlDocument class

3. Use XPath to query the version information in the xmldocument and
determine whether to download update files or not.

How do you think of this? If you feel necessary I can post some sample
code
snippet on this.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 17 '05 #7
Hi Dennis,

The reason I suggest XML file is because XML file provide well-formed
structure for storing and representing data and the classes under
System.Xml namespace has provide sufficient interfaces for us to process
XML data. For example, we have the following format of version info:

=================
<?xml version="1.0" encoding="utf-8" ?>
<versionInfo>
<latest version="1.0.4.438">
<assemblies>
<assembly fullName="System.Data, Version=1.0.2411.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
<package location="http://servername/downloaddir/myapp104438.zip" />
</assemblies>
</latest>
</versionInfo>
====================

the file is located at
http://sha-schost-01/StevenRoot/Sear...fo/version.xml

Then we can use the following
===================
string url=
"http://sha-schost-01/StevenRoot/SearchFriendApp/updateinfo/version.xml";
XmlDocument doc = null;

try
{

doc = new XmlDocument();
doc.Load(url);

XmlElement latestVersion = doc.SelectSingleNode("//latest") as XmlElement;
//display the version attribute's value
MessageBox.Show( latestVersion.Attributes["version"].Value
);

}
catch(System.Net.WebException webex)
{
txtResponse.Text += "\r\n" + webex.ToString();
}
catch(Exception ex)
{
txtResponse.Text += "\r\n" + ex.ToString();
}
finally
{
sr.Close();
}
=====================

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 17 '05 #8
Steven:

That is a geat help!

But, I was expecting something about the use of HttpWebRequest as mentioned
in your last two posts.

Also you have a line sr.Close(). What is sr?

Thanks,

Dennis

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:Iy**************@TK2MSFTNGXA01.phx.gbl...
Hi Dennis,

The reason I suggest XML file is because XML file provide well-formed
structure for storing and representing data and the classes under
System.Xml namespace has provide sufficient interfaces for us to process
XML data. For example, we have the following format of version info:

=================
<?xml version="1.0" encoding="utf-8" ?>
<versionInfo>
<latest version="1.0.4.438">
<assemblies>
<assembly fullName="System.Data, Version=1.0.2411.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
<package location="http://servername/downloaddir/myapp104438.zip" />
</assemblies>
</latest>
</versionInfo>
====================

the file is located at
http://sha-schost-01/StevenRoot/Sear...fo/version.xml

Then we can use the following
===================
string url=
"http://sha-schost-01/StevenRoot/SearchFriendApp/updateinfo/version.xml";
XmlDocument doc = null;

try
{

doc = new XmlDocument();
doc.Load(url);

XmlElement latestVersion = doc.SelectSingleNode("//latest") as XmlElement;
//display the version attribute's value
MessageBox.Show( latestVersion.Attributes["version"].Value
);

}
catch(System.Net.WebException webex)
{
txtResponse.Text += "\r\n" + webex.ToString();
}
catch(Exception ex)
{
txtResponse.Text += "\r\n" + ex.ToString();
}
finally
{
sr.Close();
}
=====================

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 17 '05 #9
Thanks for your response Dennis,

You're a sharp guy :-). Actually, I did use the HttpWebRequest in the demo
code at first, however since using XmlDocument.Load method is much more
convenient and clear, so I changed to that(the sr is an instance of
StreamReader ). Well, I've pasted the complete code of using
HttpWebRequest to retrieve the xml stream from server, also using
httpWebRequest is not restricted to Xml document, we can retrieve any
static content/ dynamic document from server by it.

=============================
private void btnReadUpdate_Click(object sender, System.EventArgs e)
{

HttpWebRequest webreq = null;
HttpWebResponse webrep = null;
StreamReader sr = null;
string url= "http://servername/dirname/version.xml";
XmlDocument doc = null;
try
{
webreq = WebRequest.Create(url) as HttpWebRequest;
webrep = webreq.GetResponse() as HttpWebResponse;
sr = new
StreamReader(webrep.GetResponseStream(),System.Tex t.Encoding.UTF8);
doc = new XmlDocument();
doc.Load(sr);

XmlElement latestVersion = doc.SelectSingleNode("//latest") as
XmlElement;
txtResponse.Text += "\r\n" + latestVersion.Attributes["version"].Value;
}
catch(System.Net.WebException webex)
{
txtResponse.Text += "\r\n" + webex.ToString();
}
catch(Exception ex)
{
txtResponse.Text += "\r\n" + ex.ToString();
}
finally
{
sr.Close();
}
}
========================

Thanks & Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 17 '05 #10
Steven:]

Thank you very much, between what I was able to get from some google
searches and the stuff you have provided, it has given me a jump start into
xml, which is a new thing for me!!

Dennis
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:xe*************@TK2MSFTNGXA01.phx.gbl...
Thanks for your response Dennis,

You're a sharp guy :-). Actually, I did use the HttpWebRequest in the
demo
code at first, however since using XmlDocument.Load method is much more
convenient and clear, so I changed to that(the sr is an instance of
StreamReader ). Well, I've pasted the complete code of using
HttpWebRequest to retrieve the xml stream from server, also using
httpWebRequest is not restricted to Xml document, we can retrieve any
static content/ dynamic document from server by it.

=============================
private void btnReadUpdate_Click(object sender, System.EventArgs e)
{

HttpWebRequest webreq = null;
HttpWebResponse webrep = null;
StreamReader sr = null;
string url= "http://servername/dirname/version.xml";
XmlDocument doc = null;
try
{
webreq = WebRequest.Create(url) as HttpWebRequest;
webrep = webreq.GetResponse() as HttpWebResponse;
sr = new
StreamReader(webrep.GetResponseStream(),System.Tex t.Encoding.UTF8);
doc = new XmlDocument();
doc.Load(sr);

XmlElement latestVersion = doc.SelectSingleNode("//latest") as
XmlElement;
txtResponse.Text += "\r\n" + latestVersion.Attributes["version"].Value;
}
catch(System.Net.WebException webex)
{
txtResponse.Text += "\r\n" + webex.ToString();
}
catch(Exception ex)
{
txtResponse.Text += "\r\n" + ex.ToString();
}
finally
{
sr.Close();
}
}
========================

Thanks & Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 17 '05 #11
You're welcome Dennis,

Also, for XML interfaces and components implemented in .net, you can refer
to the following start guide:

#Employing XML in the .NET Framework
http://msdn.microsoft.com/library/en...oyingxmlinnetf
ramework.asp?frame=true

Hope also helps. Good Luck!

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 17 '05 #12

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

Similar topics

3
by: Michael Bøcker-Larsen | last post by:
Hi I'v been stuck on this problem for ages now. I have found that I'm not the only one with this problem, by looking through the different newsgroups. Hope you can help me! I know there is a...
5
by: Laurence | last post by:
In VS.2005 using VB.NET There are two versions on every project, The Assembly Version and the File Version. Why are there two different versions? As far as I can tell, there is not need for...
1
by: Jerry John | last post by:
I am working in ASP.NET with C#. I have a text file which contains datas with delimiters. For example:- MSH|^~\$|DISCHARGE|CLAY COUNTY MEMORIAL|||200502110939| I also have an XML file created...
2
by: Miro | last post by:
I will ask the question first then fumble thru trying to explain myself so i dont waste too much of your time. Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an index - i...
9
by: JimmyKoolPantz | last post by:
IDE: Visual Studio 2005 Language: VB.NET Fox Pro Driver Version: 9.0.0.3504 Problem: I currently have a problem altering a DBF file. I do not get any syntax errors when running the program. ...
3
by: seb | last post by:
Hi, I am writing to a file some basic information using the logging module. It is working but in the log file some line are printed several time. I had put some print debugging messages in the...
4
by: mcterborg | last post by:
Hello everyone, here is what I want to do. I have a ATI video card and it allows me to setup profiles for monitor configurations and so forth. The shortcut to activate one of these profiles looks...
7
by: dm3281 | last post by:
Hello, I have this non-standard XML file that I have to manually sort thru each day and verify whether various jobs finish successfully or not. This file isn't a real XML file, so I cannot appear...
4
by: Bob Altman | last post by:
Hi all, I have a C++/CLI project (VS 2005) that produces a DLL that exports C bindings. Internally, this DLL contains routines compiled with /clr. I notice that my DLL doesn't have a version...
4
by: nightscorpion | last post by:
Hello Gurus, i implemented the OpenFileDialog in my Windows Form Applications and it worked perfectly fine.However when it was run on a remote desktop i got the below error . ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.