473,325 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

FTP related classes

I'll be working with FTP uploads/downloads. May
i ask for some pointers to relevant and useful
classes already prepared for such task in the
DotNet 2.0 framework.

I'm thinking FTPConnection, UserInfo, etc.

The ultimate help would be this.
FTPConnection connection =
new FTPConnection();
connection.IP = "1.2.3.4:5678";
connection.user = "god";
connection.password = "god1234";
connection.remoteDir = "\all\things\good";
connection.localDir = "Z:\godlike stuff";
connection.Upload(fileList);

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.
Jul 27 '08 #1
6 986
K Viltersten wrote:
I'll be working with FTP uploads/downloads. May
i ask for some pointers to relevant and useful
classes already prepared for such task in the
DotNet 2.0 framework.

I'm thinking FTPConnection, UserInfo, etc.

The ultimate help would be this.
FTPConnection connection =
new FTPConnection();
connection.IP = "1.2.3.4:5678";
connection.user = "god";
connection.password = "god1234";
connection.remoteDir = "\all\things\good";
connection.localDir = "Z:\godlike stuff";
connection.Upload(fileList);
FtpWebRequest can do the most simple stuff.

See code snippet below.

Arne

============================================

public static void Upload(string localfile, string ftpurl, bool
bin)
{
FtpWebRequest req = (FtpWebRequest)WebRequest.Create(ftpurl);
req.Method = WebRequestMethods.Ftp.UploadFile;
req.UseBinary = bin;
if(bin)
{
Stream instm = new FileStream(localfile, FileMode.Open,
FileAccess.Read);
Stream outstm = req.GetRequestStream();
byte[] b = new byte[10000];
int n;
while((n = instm.Read(b, 0, b.Length)) 0)
{
outstm.Write(b, 0, n);
}
instm.Close();
outstm.Close();
}
else
{
StreamReader sr = new StreamReader(localfile);
StreamWriter sw = new StreamWriter(req.GetRequestStream());
string line;
while((line = sr.ReadLine()) != null)
{
sw.WriteLine(line);
}
sr.Close();
sw.Close();
}
FtpWebResponse resp = (FtpWebResponse)req.GetResponse();
Console.WriteLine(resp.StatusCode);
}
Jul 27 '08 #2
I use this
http://www.rebex.net/ftp.net/

I find it very good, and when I needed some help with a problem the support
was astounding. The guy manually analysed the request/response data etc
with the server and told my company how to fix the server (there was nothing
wrong with the client components). Highly recommended by me :-)
Pete

Jul 27 '08 #3
>I'll be working with FTP uploads/downloads. May
>i ask for some pointers to relevant and useful
classes already prepared for such task in the
DotNet 2.0 framework.

I'm thinking FTPConnection, UserInfo, etc.

The ultimate help would be this.
FTPConnection connection =
new FTPConnection();
connection.IP = "1.2.3.4:5678";
connection.user = "god";
connection.password = "god1234";
connection.remoteDir = "\all\things\good";
connection.localDir = "Z:\godlike stuff";
connection.Upload(fileList);

FtpWebRequest can do the most simple stuff.
I've found a class called WebClient and i've
made it work the way i wished. However, i'm
afraid that it's an old tool and i'd prefer
to use more modern versions (up to v2.0, at
least until november).

For instance, i've noticed that there seems
not to exist a facility for getting a list of
all files in a remote directory. Is that
because WebClient shouldn't be used?

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.
Jul 27 '08 #4
K Viltersten wrote:
>>I'll be working with FTP uploads/downloads. May
i ask for some pointers to relevant and useful
classes already prepared for such task in the
DotNet 2.0 framework.

I'm thinking FTPConnection, UserInfo, etc.

The ultimate help would be this.
FTPConnection connection =
new FTPConnection();
connection.IP = "1.2.3.4:5678";
connection.user = "god";
connection.password = "god1234";
connection.remoteDir = "\all\things\good";
connection.localDir = "Z:\godlike stuff";
connection.Upload(fileList);
FtpWebRequest can do the most simple stuff.

I've found a class called WebClient and i've
made it work the way i wished. However, i'm
afraid that it's an old tool and i'd prefer
to use more modern versions (up to v2.0, at
least until november).

For instance, i've noticed that there seems
not to exist a facility for getting a list of
all files in a remote directory. Is that
because WebClient shouldn't be used?
WebClient is current.

But WebClient is even more simple than FtpWebRequest.

You can list files with FtpWebRequest:

FtpWebRequest req =
(FtpWebRequest)WebRequest.Create("ftp://ftp.netscape.com/");
req.Method = WebRequestMethods.Ftp.ListDirectory;
FtpWebResponse resp = (FtpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
Console.WriteLine(sr.ReadToEnd());

Arne
Jul 27 '08 #5
>I've found a class called WebClient and i've
>made it work the way i wished. However, i'm
afraid that it's an old tool and i'd prefer
to use more modern versions (up to v2.0, at
least until november).

WebClient is current.

But WebClient is even more simple than FtpWebRequest.

You can list files with FtpWebRequest:

FtpWebRequest req = (FtpWebRequest)WebRequest
.Create("ftp://ftp.netscape.com/");
req.Method = WebRequestMethods.Ftp.ListDirectory;
FtpWebResponse resp = (FtpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
Console.WriteLine(sr.ReadToEnd());
Thanks for the answer! Now, i wonder also why
you use the factory from WebRequest and then
cast the result into FtpWebRequest? I saw that
FtpWebRequest class has its own Create method...

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.
Jul 27 '08 #6
K Viltersten wrote:
>>I've found a class called WebClient and i've
made it work the way i wished. However, i'm
afraid that it's an old tool and i'd prefer
to use more modern versions (up to v2.0, at
least until november).
WebClient is current.

But WebClient is even more simple than FtpWebRequest.

You can list files with FtpWebRequest:

FtpWebRequest req = (FtpWebRequest)WebRequest
.Create("ftp://ftp.netscape.com/");
req.Method = WebRequestMethods.Ftp.ListDirectory;
FtpWebResponse resp = (FtpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
Console.WriteLine(sr.ReadToEnd());

Thanks for the answer! Now, i wonder also why
you use the factory from WebRequest and then
cast the result into FtpWebRequest? I saw that
FtpWebRequest class has its own Create method...
Not in my version !

Arne
Jul 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: bonj | last post by:
Hello How do I declare a template class such that the template class T must implement a certain interface? e.g. interface IProvideID { int MyID; };
4
by: Sathyaish | last post by:
My question will sound daft to the good old craftsmen, but they will excuse my nescience on the subject. I come new to the Pythonic world from the land of .NET languages, VB6 and some familiarity...
7
by: Susan Bricker | last post by:
Greetings. As a relative newcomer to Access, I am having trouble deciding on how to design the form flow for updating and creating related records. I'm looking for a variety of suggestions so...
6
by: Bill Rubin | last post by:
The following code snippet shows that VC++ 7.1 correctly compiles a static member function invocation from an Unrelated class, since this static member function is public. I expected to compile the...
10
by: Kishor | last post by:
Hi, I am looking for the solution to my problem. this is related to inheritance (Inheriting properties of base class in multiple quantity) . I am writing code in VB.net language, I am having two...
3
by: michael_geller | last post by:
While experimenting with binding datasets to an MS DataGridView, I get a warning that tells me that my DataRows are "either undeclared or was never assigned". Assuming that I am reading the...
9
by: Ugur ASLAN | last post by:
Hello, I want to implement a class structure that can take a querystring and the value of querysting can be called as myClass.getQuery("test").value. I know that I can do it like...
4
by: Phill W. | last post by:
If I have a reusbale (GAC-'registered') assembly that contains two, related classes (imagine a DataSet and DataTable; the former contains instances of the latter, the latter has a reference to its...
3
by: Steven Nagy | last post by:
Hi all, ASP.NET : Framework 2.0 - C# A recent addition to my code generater will create GridView's and ObjectDataSource's in a control (ASCX). So the code gen creates an ascx, ascx.cs,...
6
by: Marco | last post by:
One of the things I like about C++ is that it doesn't force you to create fake "objects" in the OO sense. We had a debate at the office about the "right" way to encapsulate related utility...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.