Help creating service app with FTP & cmd line params
Help creating service app with FTP & cmd line params
Help creating service app with FTP & cmd line params
Help creating service app with FTP & cmd line params
Help creating service app with FTP & cmd line params
Help creating service app with FTP & cmd line params Help creating service app with FTP & cmd line params Help creating service app with FTP & cmd line params Help creating service app with FTP & cmd line params Help creating service app with FTP & cmd line params Help creating service app with FTP & cmd line params Help creating service app with FTP & cmd line params Help creating service app with FTP & cmd line params
Help creating service app with FTP & cmd line params Help creating service app with FTP & cmd line params
Help creating service app with FTP & cmd line params
Go Back  Xtreme Visual Basic Talk > > > Help creating service app with FTP & cmd line params


Reply
 
Thread Tools Display Modes
  #1  
Old 06-23-2010, 09:13 AM
DMC1 DMC1 is offline
Newcomer
 
Join Date: Jun 2010
Location: USA
Posts: 2
Question Help creating service app with FTP & cmd line params


My first post as an absolute last resort. In 8 years of programming, I have never posted to a programming forum and have always been able to wiggle my way out of any diffficult project...Until this project. Every step of this project is new for me (Windows service, ini file, IIS, FTP, cmd line params, comparing file specs programmatically, using a timer, and even VB.NET is still confusing to me after several years in VB6 ). Dreading posting b/c I have so many questions. I have finished the internet, been to the end and back. Found endless suggestions of code and links and forums and only gotten more lost in the process...So any help is appreciated.

I am trying to create a VB.NET app, that most likely will need to be a service, for our external clients' PCs. These PCs are not connected to our network. This app will be invisible to the user and will need to perform several tasks including:

- Accept UID & PW cmd line params upon installation to be used to access client-specific FTP site for downloading latest exe and uploading completed xml files.
- Run the exe (3rd party audit exe) on client pc to generate xml files
- Check that the audit is finished running and, hence, the xml file is completed before uploading it via FTP
- Check mod date of FTP audit exe compared to local copy to determine need to download new file, or just blindly d/l exe prior to running it every time.
- use a timer to run the audit exe every 7 days
- self destruct if our relationship with the client ends without sending someone there to uninstall. Maybe just disable their FTP folder and leave software on their machine.

Some of the roadblocks I am running into are:

- Can't attach the IDE to the running service. I save and build in debug mode, run installutil, start the service, and attach IDE to that service, have breakpoints in the code, nothing happens. Maybe should make it a regular app that runs as a service rather than telling VS that it is going to be a service. Only time it falls into the code is sometimes I was able to get it in the OnStop routine when I stop it but that is useless. Have tried several ideas including:

Code:
#If DEBUG Then
        ' When debugging a service, you have to attach to a running process. This gives me 
        ' time to attach for debugging to slowdown startup so I can set a breakpoint. 
        System.Threading.Thread.Sleep(15000)
#End If
- I can't seem to programmatically specify the path of the local file to u/l or local destination to d/l to when dealing with FTP. Seems there is a default directory in IIS that I can't change programmatically. I want to hard-code a standard directory to create aon all the PCs and use that for the local files and not have to manually change that in the IIS interface.
- Have seen several very different ideas for coding FTP but not sure why I need to code for a FTP response, or why I would open the source and destination files and streamread one into another, I want a command to copy and give it the 2 file names. Here is one sugeestion I still haven't tried yet:

Code:
My.Computer.Network.DownloadFile("ftp://sitepath", "destination\filename", "userid", "password")
Or what about this one, it says download file but what file and where to copy it to? It seems to download to the default IIS directory but I want to specifiy the path:

Code:
        Dim ftp As System.Net.FtpWebRequest = CType(System.Net.FtpWebRequest.Create(URI), System.Net.FtpWebRequest)

        'Set the credentials
        ftp.Credentials = New System.Net.NetworkCredential(username, password)

        'Turn off KeepAlive (will close connection on completion)
        ftp.KeepAlive = False

        'we want a binary 
        ftp.UseBinary = True

        'Define the action required (in this case, download a file)
        ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile
- Several suggestions on the net mention namespaces and classes that I simply do not have, so I should mention I am using VB.NET 2008, not C#.
- Not sure how to best make use of an ini file idea, what to store, when/how to access it...
- How to install it simply with a single command line with params.
- I have lookde into using the WMI and bypassing this proprietary audit software to do it myself. That looks promising but will require a lot of work to mimic the expected format and content in the xml file so it seems easier to just shell to this audit prog to do it, but here I am.
- Several forums want you to d/l their code rather than just showing it and copy / paste, I don't trust that, is that common to just d/l random code and hope it doesn't have malware?
- Most suggestions found online are from 6+ years ago and related to some other software or environment and the code doesn't work copy/paste. I can't debug it because it is someone else's suggestion of code that is foreign to me. I don't have classes and namespaces memorized!

Some links I have used:
http://www.codeproject.com/KB/IP/Ftp...w=Quick&fr=201
http://www.devasp.net/net/articles/display/280.html
http://social.msdn.microsoft.com/For...b-7d774e2fa294

Sorry so long. Thanks for reading,
DMC1
Reply With Quote
  #2  
Old 06-23-2010, 11:32 AM
DMC1 DMC1 is offline
Newcomer
 
Join Date: Jun 2010
Location: USA
Posts: 2
Default

Update - I tried the single line idea

Code:
My.Computer.Network.DownloadFile("ftp://sitepath", "localdestination\filename", "userid", "password")

My.Computer.Network.UploadFile("localsource\filename", "ftp://sitepath", "userid", "password")
Here is a link with more info about this method:
http://vbnotebookfor.net/2007/09/21/...mputernetwork/

And it is amazing! It actually does what I want as far as upload / download of a file with freedom to specify source & destination, doesn;'t require any preperation programming, no variables, no mess. Just one line, so I wonder what the catch is? I bet it doesn't allow for selecting *.txt from the FTP follder to copy to local folder, just one at a time or I could be wrong.

Anyone know what any problem is with using this method? Maybe it is not going to work once I get to the environment where my client PC is not connected to the network? For now I am testing with the localhost connection.
Reply With Quote
Reply

Tags
cmd, ftp, service, timer, vb.net


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Help creating service app with FTP & cmd line params
Help creating service app with FTP & cmd line params
Help creating service app with FTP & cmd line params Help creating service app with FTP & cmd line params
Help creating service app with FTP & cmd line params
Help creating service app with FTP & cmd line params
Help creating service app with FTP & cmd line params Help creating service app with FTP & cmd line params Help creating service app with FTP & cmd line params Help creating service app with FTP & cmd line params Help creating service app with FTP & cmd line params Help creating service app with FTP & cmd line params Help creating service app with FTP & cmd line params
Help creating service app with FTP & cmd line params
Help creating service app with FTP & cmd line params
 
Help creating service app with FTP & cmd line params
Help creating service app with FTP & cmd line params
 
-->