FTP a file in .net - c#

I am looking to move a file from a directory on a server to a file share using a process running out that server already.
I want to know the best way to do this using the ftp protocol. My initial thoughts on how to do this were to use System.Net.FtpWebRequest... I will probably end up using this, but it looks like there may be some problems with it. To see what I mean check out the following link...'
See What I mean
That being said, in that article, he listed some other libraries that might be of use. Has anyone used any of these libraries? Would it be a good idea for me to try these out? Or should I just stick with FtpWebRequest. I will only be uploading a small file, and maybe it is not worth the time learning new libraries

If you are moving a file from a local server to a path accessible by network share from that server then there is no need to use FTP, you could just use File.Copy()

Personally I use the SSH.NET Library found over on Codeplex for its ability to use SFTP. You did not mention if security,encryption or compression was a requirement but this is a pretty tight little port over from java that runs in .NET 4.0

I've successfully used the FTPWebRequest on many projects without any problems. As long as you don't need implicit SSH functionality, .NET rocks!!
Here is a tutorial I've written on how to go about creating an FTP client in VB.NET:
http://dot-net-talk.blogspot.in/2008/12/how-to-create-ftp-client-in-vbnet.html
Here is the open-source library of an ftp client I've coded in C#:
http://libftp.codeplex.com/

Related

SCP Command in Solaris to file transfer from c#

Is There any way to do following in C#.NET or JAVA,
Get list of files from specific directory of Another pc having solaris OS and transfer file using SCP to another pc which have also solaris OS.
Actually i am thinking about creating front-end in asp.net to transfer backup from Live to backup server and get information about backup.
I even this is possible or not, but I wan't to clear my confusion on this.
Please give me your suggestion.
C# or any other .NET language is specific for Windows and won't run on anything but Windows. So forget about .NET languages. For this type of task I would definitely use Java if you insist on using a programming language at that level.
From Java you can use JSch library. It can do SCP from within Java. Here's is one example.
However I must say that most people that are familiar with Unix/Linux would probably simply do this task from within a scripting environment. Heck it can be done from Bash if you like.
Regardless of your choice of tool/prg.language you'll also have to decide if your doing PUSH or PULL. It seems from your posting that you are most keen on doing a PULL. There's no right or wrong answer on PUSH vs PULL.

SkyDrive as patcher storage server

As of late, we started a pretty large project (C# XNA game).
It seemed to be pretty obvious solution to store all the files in a remote server, use a database for file "versions" and have the patcher download the newer versions and delete any archaic.
Now this is all nice in theory, we even found a service with the space for it (SkyDrive with the 25GB offer).
The problem came up when it got to file manipulations.
We're looking for:
Can programmatically download/upoad (for the patch maker) files to/from SkyDrive.
Has a secure way of containing uname/pass.
Allow me to explain both.
Thing is, we had to make the SkyDrive on my personal account (due to the 25gb offer only being there for old users). I'm not very happy with someone getting my password, even though I'll obviously change it to something completely archaic, they would still get access to most of my other hotmail/msn related stuff. (I guess it's a reason to remake it all then?). So if possible I would secure the actual uname/pass inside the program. Since it's .NET and is compiled on demand, (and can easily be decompiled) I'm having doubts real security in this case is improbable (if it is possible to secure please do tell me how).
On top of that, there's no efficient&official SkyDrive API. This means that there's an even bigger security hole (see previous paragraph) and the communication won't necessarily work as expected). This also means there may be slowness in communication - something bad if you have 1000 users downloading the same file.
So to formulate all of this:
What is the the proper way (read API) to use SkyDrive as a storage server for a patcher considering it's linked to my personal account?
small sidenote, if I must, I can be evil and get our slow artist to host the server
Edit 1:
The idea is to have anyone be able to download the client, but initiating anything requires an active account on our database. As such the files themselves don't have a problem being read by everyone. So I'll add the following: how to programmaticaly get direct downloads from SkyDrive if the files are public? The current links lead to their web UI. And I mean programmatically (maybe during upload time) as to avoid doing it all by hand.
This is a bad idea.
Given #1:
Use a public folder to store your assets and grant everyone access to it
Use httpclient to download the files from the public folder anonymously in your patcher client
Use the SkyDrive descktop client to synchronize the public folder from a 'build' machine

Run C# File on the internet like a CGI File

I have a Visual C# project on my computer and I would like my users to be able to interact with it through a web browser. I've done my research, and I understand that I will probably use CGI to do this.
However, while I have been able do this with .pl and .cpp files, i can't figure out how to to it with C sharp (.cs) files. Can anyone explain how I would do this?
EDIT: If there is an alternate solution wherein the webpage communicates my C# program as a back-end program, that works, too.
UPDATE: After cancelling with my hosting provider and setting up a home-based web server (windows), I finally got the C# file to run as CGI. Thanks to everyone for your help!
You've got to give us some context ... why wouldn't asp.net be an option? If you simply don't want to run in the context of IIS, you could simply write a windows service (and expose WCF services, or even raw sockets if that's what you need).
edit: in response to the recent comment about the server being UNIX, you can use MONO to run .net code on that server: http://www.mono-project.com/Main_Page
You can either use something like mod_mono or if you'd prefer something different, you can look at manos de mono
First, I assume you have the Mono project compiler and runtime environment installed on your system.
CGI takes place entirely via standard input and standard output. (This is one reason why it is so easy to write CGI scripts in Perl, Python, Ruby, etc. You just start reading standard input as usual, parse the variables, and write whatever output you want the client to see.) Don't forget that you're responsible for the entire header, including Mime type.
If you need something that performs faster than CGI's constant fork(2)+execve(2) re-starting your CLR over and over again, you can implement the FastCGI protocol (at least, I didn't see a C# implementation on the Wikipedia page) yourself using sockets and start your CLR once only, so you have some reasonable performance. (I seem to remember Nat being passionate about the Mono process start time being "fast enough" to use it for interactive commands, so perhaps a lightly-loaded server won't have any trouble with plain old CGI interface.)

Free webstorage that is accessible via code

I have a desktop app for personal use and I would like it to be able to synchronize it's data with the net.
Since it's not trancational, I figured a solition migth be to (de)serialize the lot to a plain text format and store that in some file on the web.
Now I am looking for free storage in a way that I can access it via code, be it HTTP or FTP, that's all equal to me. Of course I would like it to 'steady', so not some obscure free service that can be stopped at any time without prior notice or services with bad connctions/ lots of downtime.
Also it would be nice if the data wasn't readily available for anyone who happens to google the right term, but that's optional since I can encrypt it.
I was thinking about google docs, but really anything will do as long as it is
free
steady (stable/trustworthy)
accessible via code
password protected (optional)
It would be very nice when codesnippets would come with the suggested solution!
I'm using C#
Softronics is a swiss hosting company that offers mydrive, a free 2GB WebDAV storage package.
They also host 2 Gigs of FTP for €1,20 a month
Some of the the Dropbox addons provide various Ruby, Python and PHP scripts and APIs for interacting with your storage space. I would probably start with the Ruby API and write a quick C# version if I were you.
If you do, can you publish it? :)
Not free, but pretty cheap - I use SugarSync. Just mark the local folder and it's automatically synched to the remote server. Version history and multi-machine sync too.

Implementing an SNMP Reporter (agent) in C# (must run on Mono)?

I am attempting to implement some additional statistics gathering in a C# server application - I have about 20 or so variables I'd like to be able to report to network monitoring tools; so I am assuming (hopefully correctly) that SNMP is the correct way to go.
There are however two problems:
The application is an open source server that cant include proprietary components, and
It needs to run on Mono under *nix environs as well as Windows via .NET.
The "#SNMP" library at http://sharpsnmplib.codeplex.com/ appears to be a promising solution - but there are no samples I can find; and my knowledge of SNMP is lacking.
Does anyone here have any (quick) examples of reporting data via SNMP? (ideally using a library under the LGPL, X/MIT, BSD or Zlib licenses)
Help much appreciated
Edit:
The problem appears to be a lack of libraries capable of acting as SNMP servers, if anyone is aware of any - this would probably solve the problem nicely.
Edit #2:
Basically I'm looking for a SNMP server library or sample reference implementation.
As the author :) I suggest you check out TestAgent sample. It can send out TRAP or INFORM messages to the IP address you specify.
Note that this is a tiny sample, which does not reveal all powers of SNMP.
#SNMP source comes with some samples (they're actually tests, but one can have an idea about how it works).
Another thing you could try is send your snmp queries calling directly the snmpget executable with the Process class. It's not the best way, but it could work (I've used this kind of approach with another language).

Categories