[RESOLVED] dynamically check version of exe file in FTP - VB.Net
to find version of an exe, i use this code
Code:
Dim FileProperties As FileVersionInfo = FileVersionInfo.GetVersionInfo(Application.ExecutablePath)
Textbox1.Text = FileProperties.FileVersion
How come we find a version of an exe that's uploaded in FTP? i need the version of an exe that's already there in FTP. i know the path where the exe file is saved in FTP.
if you have any idea, please help me...
Thanks in advance...
Re: dynamically check version of exe file in FTP - VB.Net
In my application I include version into file name then I use .ListDirectory to get files list and extract version from the name
vb.net Code:
wtheFTP.Method = WebRequestMethods.Ftp.ListDirectory
Hope this help.
Re: dynamically check version of exe file in FTP - VB.Net
Thanks mrjohn for your reply...
so we cannot get version number of an exe from FTP.
if you include version into file name, then how come you check the exact file from .ListDirectory.
what i'm trying to do is, i need to check the version number of exe in FTP and check version number of exe in local machine. if it's different, then need to download exe from FTP.
Thanks in advance.
Re: dynamically check version of exe file in FTP - VB.Net
FTP protocol provides little help for that.
In order to get the version either place it in the file name or place some other file on the ftp server. It can contain the current version in its name (the wastest way).
To update you should place the executable on the server and update the version information file.
I've used a similar approach with the only difference that I placed 'version.txt' file on the server and put the version inside. It was only after when I realized that I could get by without downloading by simply looking for a filename that fits some pre-determined pattern.
Re: dynamically check version of exe file in FTP - VB.Net
thanks cicatrix for your reply...
so in order to find the version number, i need to create 'version.txt' in FTP and put exe's version inside that. and when i want to check version number from FTP, then download version.txt file and read the version number.
That's what you mentioned? is that right?
Thanks in advance...
Re: dynamically check version of exe file in FTP - VB.Net
Either like that, or simply put a file ver0001 on the ftp folder (version 1) then change it to ver0002 (version 2), etc.
In this case you wouldn't even have to download it - you can read version right from the file name.
Re: dynamically check version of exe file in FTP - VB.Net
thanks cicatrix for your reply.
i will try that and will let you know about that.
Re: dynamically check version of exe file in FTP - VB.Net
You're welcome !
We have files like this :
myAPP_1_0_1_69.exe
vb.net Code:
wtheFTP = CType(System.Net.WebRequest.Create(wFTPupdPath), Net.FtpWebRequest)
wtheFTP.Credentials = New NetworkCredential(wFTPUsr, wFTPsw)
wtheFTP.Method = WebRequestMethods.Ftp.ListDirectory
Dim listResponse As FtpWebResponse = CType(wtheFTP.GetResponse, Net.FtpWebResponse)
Dim reader As StreamReader = New StreamReader(listResponse.GetResponseStream())
While reader.Peek >= 0
wrLN = reader.ReadLine
If wrLN.ToLower.StartsWith(Me.wAppMsk.ToLower) Then Me.wstrVerFTP = wrLN
End While
If Not (reader Is Nothing) Then
reader.Close()
reader.Dispose()
End If
.....................
Me.wstrVerFTP = Me.wstrVerFTP.Substring(10, Me.wstrVerFTP.Length - 10).Replace(".exe", "")
Dim wArrTmp() As String = Me.wstrVerFTP.Split("_"c)
If wArrTmp.Length = 4 Then
wVer_Maj = CInt(wArrTmp(0))
wVer_Min = CInt(wArrTmp(1))
wVer_Bui = CInt(wArrTmp(2))
wVer_Rev = CInt(wArrTmp(3))
End If
So with .ListDirectory you get a list of files in ftp directory,then you get the file name wanted :
vb.net Code:
....
If wrLN.ToLower.StartsWith(Me.wAppMsk.ToLower) Then Me.wstrVerFTP = wrLN
...
then extract version from the name as above
1 Attachment(s)
Re: dynamically check version of exe file in FTP - VB.Net
Attached Class used for downloading files from FTP.
the exe name is getting too big. so instead of adding the version number in exe name, i will create a text file in that folder that contains verison number. so i can check this .txt file name to get version number.
for example: the text file name is going to be Ver.1.0.0.34.txt. 1.0.0.34 is version number, that keeps on change.
is there a way i can check the file that starts with "Ver" and ends with ".txt". so i can find the version number.
how come i check the file name from FTP?
if you have any idea, please let me know.
Thanks in advance...
Re: dynamically check version of exe file in FTP - VB.Net
Thanks for your help. i tried the code you mentioned.
Code:
wtheFTP = CType(System.Net.WebRequest.Create(wFTPupdPath), Net.FtpWebRequest)
wtheFTP.Credentials = New NetworkCredential(wFTPUsr, wFTPsw)
wtheFTP.Method = WebRequestMethods.Ftp.ListDirectory
and import
Code:
Imports System.Web
Imports System.Net
Imports System.Net.WebRequest
but it says "Type FTPWebREquset is not declared".
also "Type WebRequestMethods is not declared".
also "Type FtpWebResponse is not declared".
whether I'm missing any declarations??? if you have any idea what's wrong with my code, please let me know.
Thanks in advance.
Re: dynamically check version of exe file in FTP - VB.Net
Thanks everyone for your help
in the attached file, function GetFileList there is a line
Code:
mess = m_sMes.Split(seperator)
mess is an array of string:
So if the fucntion GetFileList you are reading the file names into the array 'mess'. So you need a new function to get the version, you already have the filenames in a string array. Pass 'mess' array into a function to loop through the array and do some string compair to find the file you need.
Code:
Public Function GetVerFile(ByVal mess() As String)
Dim VerFileName As String
For Each strfile In mess
If strfile.SubString(0, 3) = "Ver" And strfile.Substring(strfile.length - 3, 3) = "txt" Then
''do some code here. If code is here then strfile must start with 'Ver' and end with 'txt'. This is persuming that the names returned in the array have the extension on the end.
End If
Next
Return VerFileName
End Function
Re: dynamically check version of exe file in FTP - VB.Net
I've created a new project and with this import :
there is no error there
vb.net Code:
Dim wtheFTP As FtpWebRequest
Dim wpWebLocation, wpUsr, wpPsw As String
Cursor.Current = Cursors.WaitCursor
wtheFTP = CType(System.Net.WebRequest.Create(wpWebLocation), Net.FtpWebRequest)
wtheFTP.Credentials = New NetworkCredential(wpUsr, wpPsw)
wtheFTP.Method = WebRequestMethods.Ftp.ListDirectory
Re: [RESOLVED] dynamically check version of exe file in FTP - VB.Net
Thanks mrjohn for your reply.
as you said i tried that code.
but it says "Type FTPWebREquset is not declared".
also "Type WebRequestMethods is not declared".
also "Type FtpWebResponse is not declared".
is it because i'm using vb.net 2003....
Thanks in advance.