Windows application to upload files - c#

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.

Related

Need help from someone who understands servers, and downloading files in c#

Let me start by describing what I want to do:
I have a Unity app, and I code it in c#.
In the app I want to download a file from a server, so I am using HttpWebRequest.
I sent out a HEAD request first to see if the file on the device needs to be updated or not, and to see the file size on the server. If the file needs to be updated I download it.
The class that I use for the downloads is in this git.
Now my problem is I don't know how to host the files because of the following issues:
I tried hosting it on a site with direct download links like ge.tt, but it does not support the HEAD request.
I tried hosting it on a free web host (000webhost), but the download gets stuck most of the time (for large files).
I tried hosting it on Dropbox but the function webRequest.EndGetResponse never returns.
I think the best solution would be to host the files on my computer, but I dont know how to do that, or how to get a download link that will work outside of my lan.
I would greatly appreciate any ideas you have, and answer questions about the code.
Thank you!

ASP.Net Controlled FTP Site

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.

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

How do I download a file in C# using webclient?

I have a Java application that downloads a file from a remote server. I would like to know where the application actually downloads a file. I captured a TCP/IP packet and found the below information.
protocol: TCP
remote address: xxx.xxx.xxx.xx
local port: xxxx
remote port: xxxxx
I know exact file URL now. However, when I try to access the file using web browser I see:
Internet Explorer cannot display the webpage
Since the application is compiled by java, there must be a way to do it in C#.
Just because the Java application is able to download the file doesn't mean they're doing it via HTTP. The fact that IE fails to display anything useful suggests it's not HTTP, although that's no guarantee.
You should look at how the Java application downloads the file, and determine the protocol - that should tell you how to do the same thing from C#.
Of course, this is assuming you have the code for the Java application. If you don't, but you think the authors would be happy for you to download the file with your own code in C#, I suggest you email them to ask them the protocol. If they don't want you accessing the file other than with their application, I'd personally respect their wishes.

FTP Login using Windows Credentials

We have a C# windows application that needs to be able to connect to a server on a network, download and save a file to a specified location.
We can not use a web service as we can not assume that our clients will have IIS on their server.
The way that I am considering doing it is to FTP onto the server and download the file. I can write the code to connect to the server and located the file but I have 2 questions.
Is there a way of using the windows credentials to FTP on to the remote server? (I understand that I cannot directly get the user's password).
Is there a better way of getting the file from a server other than ftp-ing on to it?
Thanks for the advice.
I'm assuming that a network share isn't an option (perhaps an external site etc).
Note that IIS isn't the only way of hosting a web-service. With WCF, you can use a console exe or a windows service to host the WCF service, which would allow you to run WCF on the server without any mention of IIS. See here. Then all you need is line-of-sight to the server, and some code that returns the file (or chunks of it, or a stream of it).
Depending on the size of the file (e.g. if it is less than 4MB) - you might consider leveraging a public MSMQ mechanism.

Categories

Resources