Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using FTP and clearing out memory
Message
De
25/04/2013 16:36:59
 
 
À
25/04/2013 15:30:25
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01571897
Message ID:
01571917
Vues:
79
This message has been marked as the solution to the initial question of the thread.
>>I was going to suggest something similar
>>
>>In addition to Disposing of the StreamReader, I think you need to do the same for
>>
>>
>>loFtpWebResponse.GetResponseStream()  // the stream
>>loFtpWebResponse 
>>
>
>Isn't loFtpWebResponse.GetResponseStream() already part of the Using?

Yes - but that is to Dispose() of loStreamReader




>
>>In addition, could you reuse the following (rather than instantiating each time)
>>
>>New Uri(lcURI)
>>New System.Net.NetworkCredential(cUsername, cPassword)
>>
>
>This, I do not understand. Are you saying I could get rid of the New in each of those two lines?


Yes

something like
			// this part outside the loop - even at class level if possible

			Uri uri = new Uri(lcURI);
			NetworkCredential credentials = new System.Net.NetworkCredential(cUsername, cPassword);
			// end part outside the loop

			// FTP setup
			var loFtpWebRequest = System.Net.FtpWebRequest.Create(uri);
			loFtpWebRequest.Credentials = credentials;
			loFtpWebRequest.Method = System.Net.WebRequestMethods.Ftp.ListDirectoryDetails;

			// If we use FTP/SSL  (AUTH SSL)
			// If ( nNoFTPProtocol == 2) 
			//     loFtpWebRequest.EnableSsl = true;
            

			using ( var loFtpWebResponse = loFtpWebRequest.GetResponse() )
			{
				using ( var s = loFtpWebResponse.GetResponseStream())
				{
					using( var loStreamReader = new StreamReader(s) )
					{
           
						// Load the files into the string builder
						loStringBuilder.LoadString(loStreamReader.ReadToEnd());
					}
				}
			}

		}
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform