Click here to Skip to main content
15,905,504 members
Home / Discussions / C#
   

C#

 
AnswerRe: multiple loops Pin
Seishin#29-Aug-07 3:10
Seishin#29-Aug-07 3:10 
GeneralRe: multiple loops Pin
Spacix One29-Aug-07 7:18
Spacix One29-Aug-07 7:18 
AnswerRe: multiple loops Pin
Luc Pattyn29-Aug-07 4:44
sitebuilderLuc Pattyn29-Aug-07 4:44 
QuestionMissing namespaces... Pin
Tarun.Suneja29-Aug-07 1:36
Tarun.Suneja29-Aug-07 1:36 
AnswerRe: Missing namespaces... [modified] Pin
Vasudevan Deepak Kumar29-Aug-07 2:02
Vasudevan Deepak Kumar29-Aug-07 2:02 
GeneralRe: Missing namespaces... Pin
Tarun.Suneja29-Aug-07 2:19
Tarun.Suneja29-Aug-07 2:19 
GeneralRe: Missing namespaces... Pin
Vasudevan Deepak Kumar29-Aug-07 3:19
Vasudevan Deepak Kumar29-Aug-07 3:19 
QuestionGet list of files from ftp Pin
toink toink29-Aug-07 1:30
toink toink29-Aug-07 1:30 
I found an ftp client class from this site and I used the List Function which is as follows:

public ArrayList List()
{
Byte[] bytes = new Byte[512];
string file_list = "";
long bytesgot = 0;
int msecs_passed = 0;
ArrayList list = new ArrayList();

Connect();
OpenDataSocket();
SendCommand("LIST");
ReadResponse();

//FILIPE MADUREIRA.
//Added response 125
switch(response)
{
case 125:
case 150:
break;
default:
CloseDataSocket();
throw new Exception(responseStr);
}
ConnectDataSocket(); // #######################################

while(data_sock.Available < 1)
{
System.Threading.Thread.Sleep(50);
msecs_passed += 50;
// this code is just a fail safe option
// so the code doesn't hang if there is
// no data comming.
if (msecs_passed > (timeout / 10))
{
//CloseDataSocket();
//throw new Exception("Timed out waiting on server to respond.");

//FILIPE MADUREIRA.
//If there are no files to list it gives timeout.
//So I wait less time and if no data is received, means that there are no files
break;//Maybe there are no files
}
}

while(data_sock.Available > 0)
{
bytesgot = data_sock.Receive(bytes, bytes.Length, 0);
file_list += Encoding.ASCII.GetString(bytes, 0, (int)bytesgot);
System.Threading.Thread.Sleep(50); // *shrug*, sometimes there is data comming but it isn't there yet.
}

CloseDataSocket();

ReadResponse();
if (response != 226)
throw new Exception(responseStr);

foreach(string f in file_list.Split('\n'))
{
if (f.Length > 0 && !Regex.Match(f, "^total").Success)
list.Add(f.Substring(0, f.Length - 1));
}

return list;
}

But everytime I get files from ftp using this function it includes a date plus other characters plus the name of the file itself.

For example: I want to get all the files inside a certain folder in ftp. The filenames of which are Text1.txt, Text2.txt and Text3.txt. Yet when i tried to retrieve its files using this function, it returns
08-29-07 06:42PM 0 Test1.txt
08-29-07 06:42PM 0 Test2.txt
08-29-07 06:42PM 0 Test2.txt

My question is, how can i retrieve files from ftp returning only the original filenames which are Text1.txt, Text2.txt and Text3.txt.

Thanks
AnswerRe: Get list of files from ftp Pin
Vasudevan Deepak Kumar29-Aug-07 2:03
Vasudevan Deepak Kumar29-Aug-07 2:03 
QuestionBinding GridView to a child obect in a list Pin
oceanexplorer29-Aug-07 1:01
oceanexplorer29-Aug-07 1:01 
QuestionPerfect Timing! Pin
pokabot29-Aug-07 0:52
pokabot29-Aug-07 0:52 
AnswerRe: Perfect Timing! Pin
J4amieC29-Aug-07 1:04
J4amieC29-Aug-07 1:04 
GeneralRe: Perfect Timing! Pin
originSH29-Aug-07 1:11
originSH29-Aug-07 1:11 
AnswerRe: Perfect Timing! Pin
Christian Graus29-Aug-07 2:05
protectorChristian Graus29-Aug-07 2:05 
GeneralRe: Perfect Timing! Pin
pokabot29-Aug-07 3:00
pokabot29-Aug-07 3:00 
AnswerRe: Perfect Timing! Pin
Hessam Jalali29-Aug-07 5:08
Hessam Jalali29-Aug-07 5:08 
QuestionsaveFileDialog Pin
lourensG29-Aug-07 0:28
lourensG29-Aug-07 0:28 
AnswerRe: saveFileDialog Pin
blackjack215029-Aug-07 0:39
blackjack215029-Aug-07 0:39 
GeneralRe: saveFileDialog Pin
lourensG29-Aug-07 0:46
lourensG29-Aug-07 0:46 
GeneralRe: saveFileDialog Pin
Vikram A Punathambekar29-Aug-07 0:58
Vikram A Punathambekar29-Aug-07 0:58 
GeneralRe: saveFileDialog Pin
blackjack215029-Aug-07 1:59
blackjack215029-Aug-07 1:59 
QuestionHow to get the specified process Pin
Situ1429-Aug-07 0:09
Situ1429-Aug-07 0:09 
AnswerRe: How to get the specified process Pin
Martin#29-Aug-07 0:18
Martin#29-Aug-07 0:18 
AnswerRe: How to get the specified process Pin
Luc Pattyn29-Aug-07 2:10
sitebuilderLuc Pattyn29-Aug-07 2:10 
Questionpic in crystal reports Pin
Sonia Gupta28-Aug-07 23:13
Sonia Gupta28-Aug-07 23:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.