ASP.Net Controlled FTP Site - c#

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.

Related

How to dump an xml file generated from server to a random client, but I have to damp that file in a specific folder of clients

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)

Automatically upload newly created files to an SFTP server

An ASP.NET application (running on Windows server/IIS 7) has to transfer big size files uploaded by current user to an external SFTP server. Due to the file size the idea is to do this asynchronously.
The idea is that the ASP.NET application stores the uploaded file on a local directory of the Windows server. The current user can continue his work. A Windows service or a Quartz job (other tools(*)/ideas?) is now responsible to transfer the file to the external SFTP server.
(*) Are there existing tools that listen on changes of a Windows directory and then move the files on a SFTP server (incl. handling communication errors/retries)?
If there is no existing solution, do you have had similar requirements? What do we have to consider? Because the connection to the SFTP server is not very stable we need an optimized error handling with auto retry functionality.
To watch for changes in a local directory in .NET, use
the FileSystemWatcher class.
If you are looking for an out of the box solution, use the keepuptodate command in WinSCP scripting.
A simple example of WinSCP script (e.g. watch.txt):
open sftp://username:password#host/
keepuptodate c:\local_folder_to_watch /remote_folder
exit
Run the script like:
winscp.com /script=watch.txt
Though this works only, if the uploaded files are preserved in the remote folder.
(I'm the author of WinSCP)

Microsoft Sync Remote Files?

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

Windows application to upload 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.

sync database to uploaded file using Windows Service or website code

I have a website that occasionally needs to have a handful of the tables in its database updated. The updates come from another system that exports to comma delimited text files. I can then either FTP the text files to the web server, send them in through an admin upload page, or manually log in to Remote Desktop to download the text files. I have all my C# code written to parse the files, check the database contents, and decide what to do.
Should I code the sync logic to be part of a file upload page, protected in the admin section of the site or should I create a Windows Service that constantly looks for files to process in a particular directory that I can drop files in through FTP?
I have used Windows Services in the past and they have worked great, but if I ever have to make a change to the code it can take longer than it would if I just had to modify an ASPX.
Are their security benefits one way or another?
Performance benefits?
ASPX page wins the "ease of maintenance" category.
I would create a Windows Service to watch a secure folder and use a directory watcher to look for new files. Since the files are coming from another system, it is asynchronous in nature, and it is much more performant to have a Windows Service running separately to watch for updates as they happen. It can also parse the files and update the database for you.
Depending on who maintains the remote system, the easiest way is to grant permission to the service to access the files on a secure, shared folder. Then you won't need to do anything manually.

Categories

Resources