Basically I have two parts of my application that I need help with.
I need to send an ini containing some preferences over a TCPClient socket to a client. How might I do this?
I need to scan a folder on the client side and see what is different from the folder on the server, then send the changed files.
Thanks very much,
Christian
EDITS
Potential leads:
Microsoft Sync Service - They mention that this can be used for remote files, but I have not found any explanation or code samples.
FileSync on SourceForge - Looks
good, but does it have network sync?
You could do this with Microsoft sync framework.
Here is a code sample for doing file synchronisation: http://code.msdn.microsoft.com/File-Synchronization-516e3ad7
Here's how I actually fixed this:
Client connects to server (or webserver!)
Client downloads XML with file structure, including MD5 of each file.
Client figures out which files need to be redownloaded.
New files are downloaded from server (or webserver!)
Honestly all of this can be done through a webserver approach, simply host all the files and the XML structure file on a normal webserver and then have the client use these files.
~Christian
Related
I was thinking to dump an XML file generated from server to a random client requesting that. The problem is that I have to damp that file in a specific folder of clients (C:/Application/POSMachine/WaitingXML), for there is another application listening to that folder.
My approach:
A simple patch (to change chrome download address to the specific desired path)
Installing windows service/local-api for those clients who need this feature, and passing server-side generated XML to clients installed service/api, I am assuming I will get clients IP-address from the server and hit the service hosted in clients.
Request.GetOwinContext().Request.RemoteIpAddress
Any comments and better implementation is appreciated.
It would be a security risk to allow a website to download a file to an arbitrary location (that would mean a malicious website could just download a new svchost.exe to C:\Windows\System32 or what not)
Also your idea with running a service would not work in all cases, since your clients will most probably be behind a modem/router/NAT switch (or multiple). All these devices would have to be configured for port forwarding. So, you really need an 'client-outbound' connection (like a browser does).
I would implement a client program which can contact your server and download the file with a System.Net.WebRequest and save to the specific location. Another possibility might be to add a System.Windows.Forms.WebBrowser control and handle the FileDownload event. However, your question does not contain enough information to more specific (how does the client chose a file to download)
There is a program which sends image files in binary by using WebClient.UploadFile(someUri, "STOR", filename). I can't change that program, but I need to build a program to receive the file. I don't want to implement a full FTP server, so what should I be looking at to create the bare minimum logic in C# to receive the file? A bonus would be a solution that uses features present in .NET 3.5 or 4
I don't really know where to start, so any tip is appreciated. Thanks.
It sounds like you'll need to provide not an FTP server, but an HTTP server (aka a web server). From a little quick Googling, it looks like there's a library for embedding a simple web server into a .net application named Nancy that a lot of people seem to have good results with: Embedded C# web server?
Of course, this would be the quick and dirty way. Probably a better long-term approach would be to create a normal ASP.Net website to receive the images, hosted on a normal IIS web server. But if you have no experience in web development, that might be biting off a lot.
Thank you for the suggestions, but through more digging around I found out how to implement what I need. This is a very simple ftp server done in python using sockets. I was able to easily replicate this in C# using sockets again and I have adapted it to be able to authenticate a user of my choosing and write the received files to the disk.
I need to integrate with some older software that will transfer files to our server via FTP. There is no other way to receive these files other than FTP.
As files are uploaded I would like to perform some logic.
I have no way of knowing in advance when new files will be uploaded (they are not uploaded at regular intervals).
I've created a simple Windows Service that uses the FileSystemWatcher class to monitor the root directory of an FTP site and send me an email when new files are created (email is just for demo purposes, production version will probably POST the file to our web api or something). While this works, it has a lot of "moving parks" and requires that the service be installed and running, and it doesn't seem like FileSystemWatcher is all that reliable.
Is there a way to have an ASP.Net site accept FTP uploads?
Does anyone have a better idea for handing incoming files over FTP?
The software sending the files over FTP does not need to read anything on our server, it exclusively writes files.
I need to make a windows application to upload files (jpg) that are on my computer to a web host. I have tried various codes I found on the web but none of them worked.
Does anyone have a working code to do this? Maybe in VB.NET or C#.
I appreciate the help.
Your question is not revealing more details about your requirement, but still I'm providing couple of ideas on how do that based different scenarios.
First point: you need to be clear about your server side for receiving these files. Whether you want to activate ftp on server and provide ftp credentials to client to upload files to a particular folder. If not ftp then you should have your server listen to post requests from the client to upload files.
FTP: Here is the article to upload files from windows application to a FTP server.
Post: Here is the link for post way.
I am scratching my head about this. My scenario are that I need to upload a file to the company server machine(to a folder on c:) from our hosting one(totally different server). I don't know how I should do this. Any of you got tips or code on how this is done.
Thanks Guys
I would set up an FTP server (like the one in IIS or a third-party server) on the Company Server. If security is an issue then you'll want to set up SFTP (secure FTP) rather than vanilla FTP since FTP is not a natively secure transfer protocol. Then create a service on the Hosting Server to pick up the file(s) as they come in and ship them to the company server using C#/.NET's FTP control. Honestly, it should be pretty straightforward.
Update: Reading your question, I am under the strong impression that you will NOT have a web site running on the company server. That is, you do not need a file upload control in your web app (or already know how to implement one given that the control is right in the web page toolbox). Your question, as I understand it, is how to get a file from the web server over to the company server.
Update 2: Added a note about security. Note that this is less of a concern if the servers are on the same subdomain and won't be routed outside of the company network and/or if the data is not sensitive. I didn't think of this at first because I am working a project like this now but our data is not, in any way, sensitive.
Darren Johnstone's File Upload control is as good a solution as you will find anywhere. It has the ability to handle large files without impacting the ASP.NET server memory, and can display file upload progress without requiring a Flash or Silverlight dependency.
http://darrenjohnstone.net/2008/07/15/aspnet-file-upload-module-version-2-beta-1/
There isnt enough info to tell your whole hosting scenario but I have a few suggestions that might get you started in the right direction:
Is your external server owned by another company or group and you cant modify it? If not you might consider hosting the process on the same machine, either in process or as a separate service on the machine. If it cannot be modified, you might consider hosting the service on the destination machine, that way its in the same place as the files need to show up at.
Do the files need to stay in sync with the process? I.e. do they need to be uploaded, moved and verified as a single operation? If not then a separate process is probably the best way to go. The separate process will give you some flexibility, but remember it will be a separate process and a separate set of code to manage and work with
How big is the file(s) that are being uploaded? Do they vary by upload? are the plain files, binaries (zips, executables, etc)? If the files are small you have more options than if they are large. If they are small enough, you can even relay them in line.
Depending on the answers to the above some of these might work for you:
Use MSMQ. This will work for simple messages under about 3MB without too much hassle. Its ideal for messages that can be directly worked with (such as XML).
Use direct HTTP(s) relaying. On the host machine open a HTTP(s) connetion to the destination machine and transfer the file. Again this will work better for smaller files (i.e. only a few KB since it will be done in-line)
If you have access to the host machine, deploy a separate process on the machine which builds or collects the files and uses any of the listed methods to send them to the destination machine.
You can use SCP, FTP (of any form SFTP, etc) on either the host machine (if you have access) or the target machine to host the incoming files and use a batch process to move the files. This will have a lot of issues to address, such as file size, keeping submissions in sync, and timing. I would consider this as a last resort, depending on the situation.
Again depending on message size, you could also use a layer of abstraction such as a DB to act as the intermediate layer between the two machines. This will work as long as the two machines can see the DB (or other storage location) and both act on it. SQL Server Service Broker could be used for this purpose (and most other DB products offer similar products).
You can look at other products like WSO2 ESB or NServiceBus to facilitate messaging between the two apps and do it inline.
Hopefully that will give you some starting points to look into.