Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FtpWebRequest cannot handle file with more than one spac
Message
De
28/11/2013 09:33:19
 
 
À
28/11/2013 07:02:32
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:
01588791
Message ID:
01588832
Vues:
28
>Update - I see the spaces in the filenames were addressed here message#1543391 - EndUpdate
>
>
>I suppose this is related to thread#1588792
>
>I don't really see a problem if there are consecutive spaces in the filename since we know that the filename is the last part(s) of the line
>
>(1)
>If you parse with string.Split http://msdn.microsoft.com/en-us/library/ms131448.aspx do not use StringSplitOptions.RemoveEmptyEntries
>
>
>string s = "1  2 3   4";
>string[] elements = s.Split(new char[] { ' ' }, StringSplitOptions.None);
>
>When you traverse the result, each empty string in the array represents an extra space char in the original string
>The parsing is a bit more difficult
>
>(2) if you parse with Regex, since the filename is in the last parts you can take advantage of the $ anchor
>
>(message#1543374) changed as follows
>
>- the last line - lots of spaces in the file name
>- the pattern for the filename
>was [\S]+)$
>becomes .+)$
>
>The filename of the last line is correctly parsed
>
>		internal static void Go()
>		{
>			string[] lines =
>			{	@"drw-rw-rw-   1 user     group           0 Feb  6 15:46 .",
>                @"drw-rw-rw-   1 user     group           0 Feb  6 15:46 ..",
>                @"-rw-rw-rw-   1 user     group        4825 May  3  2010 Account.png",
>                @"-rw-rw-rw-   1 user     group        5242 May  3  2010 Administration.png",
>                @"-rw-rw-rw-   1 user     group        4117 Apr 17  2011 Agent.png",
>                @"-rw-rw-rw-   1 user     group        1402 Dec 30  2005 AmazonCA.gif",
>                @"-rw-rw-r--   1 wliclus  weblogic   308121 Jun  1  2011 tlv_01_jackk_2011615315_1185655_001_23327701.zip",
>				@"-r-xr-xr-x   1 owner    group        78145990 Nov  4  2011 101.zip",
>                @"-r-xr-xr-x   1 owner    group           35492 Apr 14  2011 20110414.40E",
>                @"-r-xr-xr-x   1 owner    group           33583 Apr 14  2011 20110414.421",
>                @"-r-xr-xr-x   1 owner    group           40815 Apr 14  2011 20110414.483",
>                @"-r-xr-xr-x   1 owner    group           24836 Apr 14  2011 20110414.ARC",
>                @"-r-xr-xr-x   1 owner    group            4737 May  5  2011 4A16PBE1.txt",
>                @"-r-xr-xr-x   1 owner    group            4737 Jan 18 13:50 4A17A7B1 aa  bbb      cccccc.txt"
>			};
>
>			string pattern = @"^(?<Permissions>\S+)\s+(?<Links>\d+)\s+(?<User>\w+)\s+(?<Group>\w+)\s+(?<FileSize>\d+)\s+(?<Month>\w+)\s+(?<Day>\d+)\s+((?<Year>\d{4})|(?<Time>\d+:\d+(:\d+)?))\s+(?<FileName>.+)$";
>
>
>
>			foreach (string line in lines)
>			{
>				Match m = Regex.Match(line, pattern);
>
>				if (m.Success)
>				{
>					Console.WriteLine("Month {0}", m.Groups["Month"]);
>					Console.WriteLine("Day {0}", m.Groups["Day"]);
>					Console.WriteLine("Year {0}", m.Groups["Year"]);
>					Console.WriteLine("Time {0}", m.Groups["Time"]);
>					Console.WriteLine("Size {0}", m.Groups["FileSize"]);
>					Console.WriteLine("FileName {0}", m.Groups["FileName"]);
>				}
>				else
>					Console.WriteLine("No match");
>
>			}
>
>
>			Console.ReadLine();
>
>
>		}
>
Thanks, but I prefer to have something that I can read and evolve in exactly the way I want, especially if I have to move the framework into another development environment in the future.
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform