473,503 Members | 4,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FTP Parsing directory listings

Good day all,

Trying to get a listing of directories in a directory using FTP.

I get the following as a result:

"drw-rw-rw- 1 user group 0 Nov 2 18:39 testdir"

Anybody have a good regex expression or any ideas how I would parse
this to get "testdir" or any other method?

thanks a bunch

~Gina~

Nov 4 '06 #1
2 6777
Gina_Marano wrote:
Trying to get a listing of directories in a directory using FTP.

I get the following as a result:

"drw-rw-rw- 1 user group 0 Nov 2 18:39 testdir"

Anybody have a good regex expression or any ideas how I would parse
this to get "testdir" or any other method?
I had this old code on the shelf:

using System;

public class MainClass
{

public static string Eater(string line, int ix, int n)
{
string res = "";
int ws = 0;
for (int i = 1; i < line.Length; i++) {
if ((line[i] == ' ') && (line[i - 1] != ' ')) {
ws = ws + 1;
}
if ((ws >= ix) && (ws < (ix + n))) {
res = res + line[i];
}
}
return res.Trim();
}

public static void Parse(string line)
{
string protection = Eater(line, 0, 1);
string owner = Eater(line, 1, 3);
int size = int.Parse(Eater(line, 4, 1));
string tim = Eater(line, 5, 3);
string filename = Eater(line, 8, 100);
Console.WriteLine(filename + " " + size + " " + tim);
}

public static void Main(string[] args)
{
Parse("drwxr-xr-x 1 ftp ftp 0 Sep 01 19:38 Adobe
Illustrator 10");
Parse("drwxr-xr-x 1 ftp ftp 0 Sep 07 09:36 subdir");
Parse("-rw-r--r-- 1 ftp ftp 1871872 Sep 07 11:52 a.zip");
Parse("-rw-r--r-- 1 ftp ftp 21814474 Sep 07 09:53 z.zip");
}
}

I am not sure it is perfect, but the 4 examples in main do work.

Arne
Nov 4 '06 #2
You are great Arne!

It worked perfectly!

~Gina~

Nov 4 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1590
by: Dan King | last post by:
I have an ASP page that currently gives me an output of file listing with links to each of them for the current directory. The problem I am having is there are getting to be too many folders. I...
8
2564
by: James Owens | last post by:
I'm a relative newbie, interested in storing the information from several server directories and subdirectories in XML so that I can present it selectively using XSL (all files updated today or...
2
6790
by: John Young | last post by:
I'm trying to parse a directory, but am not sure of the best way of doing it. Preferably using only .net instructions. Can anyone give me an idea of how to do this? Thanks in advance for any...
8
11054
by: gil | last post by:
Is it possible to prevent a browser from listing the entire contents of a folder? The site, is hosted on my ISP with the following layout- site/ "user name from ISP" pagefile (dir)...
2
2502
by: Danny Boy | last post by:
Hi, "Snif" is an excellent little script to index files and directories. It's just one single file, and the advantage is that you merely drop it into the directory you want to index, point a...
2
2384
by: Gordon | last post by:
I'm trying to remove a directory and all its contents from within a script. I wrote a recursive function to take care of it, but when I run it I get random "Directory not empty" error messages. ...
4
1095
by: Name Withheld | last post by:
OK i know this is a 101 question but... ASP.NET/VB.NET ListingItems() as string I need a nested array of Listings().ListingItems() so i can read a text file and split each line and insert...
1
5639
by: Steve | last post by:
My site is hosted on a Godaddy reseller site. Godaddy only allows the use of Curl to access remote sites. What is the method for listing a directory after connecting to the site with Curl? ...
7
1864
by: samatair | last post by:
I need to change an existing listings page with pagination. Each page shows 10 listings and they are ordered by the date they are added to the site. Now recently added listings show up in the...
1
7012
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5598
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1522
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.