Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using FTP and clearing out memory
Message
From
26/04/2013 02:47:09
 
 
To
25/04/2013 17:28:38
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01571897
Message ID:
01571948
Views:
57
>BTW, if I do this triple Using cascading, I end up with this:
>
>"Overload resolution failed because no accessible 'New' can be called without a narrowing conversion"
>
>This is at the design time on the loStreamReader Using line.

I've added some static properties (uri, user, password) to test this

I have no problem with the triple using

I think we need some code of yours - the error you are getting is not related to Using - more a problem of type/casting

(update : forget the out-the-loop part for the Uri - I now see it contains the remote directory )
		public static void Main()
		{
			StringBuilder loStringBuilder = new StringBuilder();

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

			NetworkCredential credentials = new System.Net.NetworkCredential(cUsername, cPassword);
			// end part

			Uri uri = new Uri(lcURI);

			// 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.Append(loStreamReader.ReadToEnd());
					}
				}
			}
			Console.WriteLine("{0}", loStringBuilder.ToString());
			Console.ReadLine();

		}
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform