Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking for empty FTP directory
Message
De
13/01/2013 19:05:14
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Checking for empty FTP directory
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01562401
Message ID:
01562401
Vues:
54
The only way I have found so far to check if a directory exists on a FTP, when using this code, is to check if cDirectoryContentFromFTP is empty.
                        ' FTP setup
                        loFtpWebRequest = System.Net.FtpWebRequest.Create(New Uri(lcURI))
                        loFtpWebRequest.Credentials = New System.Net.NetworkCredential(cUsername, cPassword)
                        loFtpWebRequest.Method = System.Net.WebRequestMethods.Ftp.ListDirectoryDetails

                        ' If we use FTP/SSL  (AUTH SSL)
                        If nNoFTPProtocol = 2 Then
                            loFtpWebRequest.EnableSsl = True
                        End If

                        loFtpWebResponse = loFtpWebRequest.GetResponse()

                        loStreamReader = New StreamReader(loFtpWebResponse.GetResponseStream())

                        ' Load the files into the string builder
                        loStringBuilder.LoadString(loStreamReader.ReadToEnd())

                        ' Initialization
                        cDirectoryContentFromFTP = loStringBuilder.oStringBuilder.ToString
As, if the directory exists, there will be at least an entry for the current directory, or two entries, assuming the current directory is under another directory. Is there any other way to do this better?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Répondre
Fil
Voir

Click here to load this message in the networking platform