472,974 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,974 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 977
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.