Thanks for your response Thom,
As for uploading whole file/folder structure, I think we have to followup
the FTP protocol rules, create folder on the serverside first then use
upload command to upload files .... FtpWebRequest is just a raw component
which implement those basic FTP verbs. Maybe some 3rd party guys will
implement a encapsulated one which provide a uploading/downloading folder
strucure fuctionality.. I think your current application is just
something like a simple GUI WYSIWYG ftp client, yes? I think most such
FTP client application just using the basic FTP commands(upload file, make
folder...) to implement complex operations(folder structure upload...).
Thanks & Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Thom Little" <thom@tlanet.net>
| References: <uTnsZmu7FHA.3636@TK2MSFTNGP09.phx.gbl>
<33JHyyz7FHA.4000@TK2MSFTNGXA02.phx.gbl>
| Subject: Re: Single Logon
| Date: Tue, 22 Nov 2005 10:49:17 -0500
| Lines: 133
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <uaIpRx37FHA.740@TK2MSFTNGP11.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: 65.99.185.176
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:31269
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Thanks for the help.
|
| My final project in this area has probably already been done elsewhere.
I
| want to download or upload a complete tree structure. This will delete
| everything on the receiving end and then transfer the entire structure.
|
| The challenge is coming up with the recursive technique.
|
| Any leads would be appreciated.
|
| --
| -- Thom Little --
www.tlanet.net -- Thom Little Associates, Ltd.
| --
|
[quoted text, click to view] | "Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
| news:33JHyyz7FHA.4000@TK2MSFTNGXA02.phx.gbl...
| > Hi Thom,
| >
| > Welcome to ASPNET newsgroup.
| > As for the underlying internet connections which is used to serve the
| > WebRequest(HttpWebreuqest, FtpWebRequest...) calls, it is maintained by
| > the
| > underlying Connection Manager, we can not directly manually create or
| > control them. Actually in .NET System.Net namespaces , those WebRequest
| > components will retrieve a ServicePoint(which represent a connection to
a
| > remote resource ---- by URL) to perform the network operation. And these
| > SevicePoint objects are managed by the ServicePointManager... We can
| > configure some setting such as Max ServicePoint count..... (can also
| > configure through app config file). Also, for your scenario, I think
| > you
| > can consider using the "WebRequest.ConnectionGroupName" property to
| > specify
| > a certain Group Name for your FtpWebRequest components, for those
| > webrequest components which have the same ConnectionGroupName and
request
| > the same remote resource (same URL ...), the ServicePointManager (within
| > the same AppDomain) will try reusing and sharing ServicePoints for those
| > webrequest components(in same group...).
| >
| > #WebRequest.ConnectionGroupName Property
| >
http://msdn2.microsoft.com/en-us/library/system.net.webrequest.connectiongro | > upname.aspx
| >
| > #ServicePointManager Class
| >
http://msdn2.microsoft.com/en-us/library/zkfa48de(en-US,VS.80).aspx
| >
| > Hope helps. Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure!
www.microsoft.com/security | > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| >
| >
| > --------------------
| > | From: "Thom Little" <thom@tlanet.net>
| > | Subject: Single Logon
| > | Date: Mon, 21 Nov 2005 17:19:04 -0500
| > | Lines: 52
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | X-RFC2646: Format=Flowed; Original
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | Message-ID: <uTnsZmu7FHA.3636@TK2MSFTNGP09.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | NNTP-Posting-Host: 65.99.185.176
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.webcontrols:31252
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| > |
| > | The following will download every file in a remote directory ...
| > |
| > | public void DownloadDirectory(string strAddress, string
strUsername,
| > | string strPassword )
| > | {
| > | FtpWebRequest req = (FtpWebRequest)WebRequest.Create(c_strFtp +
| > | strAddress );
| > | req.Credentials = new NetworkCredential(strUsername, strPassword );
| > | req.Method = WebRequestMethods.Ftp.ListDirectory ;
| > | FtpWebResponse resp = (FtpWebResponse)req.GetResponse( );
| > | Stream rs = resp.GetResponseStream( );
| > | StreamReader sr = new StreamReader(rs, System.Text.Encoding.UTF8 );
| > | string[] strDirectory = sr.ReadToEnd().Trim( '\n' ).Split( '\n' );
| > | sr.Close( );
| > | rs.Close( );
| > | resp.Close( );
| > | foreach (string strFilename in strDirectory )
| > | this.DownloadFile( strFilename.Trim( '\r'), strAddress,
strUsername,
| > | strPassword );
| > | }
| > |
| > | private void DownloadFile( string strFilename, string strAddress,
| > string
| > | strUsername, string strPassword )
| > | {
| > | byte[] buf = new byte[2047] ;
| > | int iWork ;
| > | FtpWebRequest req = (FtpWebRequest)FtpWebRequest.Create( c_strFtp +
| > | strAddress + strFilename );
| > | req.Credentials = new NetworkCredential(strUsername, strPassword );
| > | req.Method = WebRequestMethods.Ftp.DownloadFile ;
| > | FtpWebResponse resp = (FtpWebResponse)req.GetResponse( );
| > | Stream rs = resp.GetResponseStream( );
| > | FileStream fs = new
FileStream(this.tbAddressClient.Text.ToString() +
| > | strFilename, FileMode.Create );
| > | while ( ( iWork = rs.Read( buf, 0, buf.Length ) ) > 0 )
| > | fs.Write( buf, 0, iWork );
| > | fs.Close( );
| > | rs.Close( );
| > | }
| > |
| > | ... the disadvantage is that every file downloaded requires a separate
| > | connection to be established.
| > |
| > | Is there an example of establishing a connection, downloading multiple
| > | files, closing connections?
| > |
| > | --
| > | -- Thom Little --
www.tlanet.net -- Thom Little Associates, Ltd.