Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
6.1k views
in .NET FTP by
Hi,

Im using this class. When I transfer files. it takes only file name in destination path and get the file from remote to the location, where my demo application is put . e.g. in in Demo/bin/debug. Even If I specify the full path it says access to file is denied.

Please do the needful.

sample code is given below.
error in line
ftp.Get(strfile.Name ,strfile.Name);//If the specify the path here in ist param, it gives the error

public void CopyFilesAndDir(string roolDir)
{
DirFile df;
ArrayList alDirs= new ArrayList();
ftp.ChDir(roolDir);
string[] files = ftp.Dir(".", false);
for (int i = 0; i < files.Length; i++)
foreach(string file in files)
{
try
{
FTPFile[] fp= ftp.DirDetails(file);
// FTPFile dir=(FTPFile)(file);
if(fp.Length>1) //directory

CopyFilesAndDir(file);
else
foreach(FTPFile strfile in fp)
ftp.Get(strfile.Name ,strfile.Name);//If the specify the path here in ist param, it gives the error
}
catch(Exception ex)
{
string str=ex.Message;
}
}

}

7 Answers

0 votes
by (162k points)
You need to use ChDir to change into the directory before you transfer the file

Hi,

Im using this class. When I transfer files. it takes only file name in destination path and get the file from remote to the location, where my demo application is put . e.g. in in Demo/bin/debug. Even If I specify the full path it says access to file is denied.
0 votes
by
Im changing the dir using ChDir, But I think it will change the dir of remote file on FTP.

what I want is that on the FTP there is one folder in root called VOW.
This VOW folder again contains 3 folders called
1- Doc
2- Data
3- Photo
and these 3 folders contain files.

I want to copy them locally in the folder say D:\VOW in the same heirarchy. e.g. I'll get respective files in D:\VOW\Doc\, D:\VOW\Data\ and D:\VOW\Photo\.

Instead Im getting all the files from 3 folders to C:\Demo\bin\debug\. where my demo application exe is residing.

I hope U got the problem right.

Thanks in advance.
0 votes
by (162k points)
It sounds like you want a recursive get.

It is beyond the scope of this forum to explain how to do this, but it is not that difficult a programming problem.

Alternatively, edtFTPnet/PRO's next version, being released this week, does have recursive operations - see

http://www.enterprisedt.com/products/ed ... rview.html

later this week.

Im changing the dir using ChDir, But I think it will change the dir of remote file on FTP.

what I want is that on the FTP there is one folder in root called VOW.
This VOW folder again contains 3 folders called
1- Doc
2- Data
3- Photo
and these 3 folders contain files.

I want to copy them locally in the folder say D:\VOW in the same heirarchy. e.g. I'll get respective files in D:\VOW\Doc\, D:\VOW\Data\ and D:\VOW\Photo\.

Instead Im getting all the files from 3 folders to C:\Demo\bin\debug\. where my demo application exe is residing.

I hope U got the problem right.

Thanks in advance.
0 votes
by
Hi,

Thanks. I know it is not that difficult programatically. Im able to get all files recursively.but they get downloaded in the directory where the exe resides and not in the my own defined direcory.

that's why I needed a way to specify full local path.
Can U pls guide me in that

Thanks

It sounds like you want a recursive get.

It is beyond the scope of this forum to explain how to do this, but it is not that difficult a programming problem.

Alternatively, edtFTPnet/PRO's next version, being released this week, does have recursive operations - see

http://www.enterprisedt.com/products/ed ... rview.html

later this week.

Im changing the dir using ChDir, But I think it will change the dir of remote file on FTP.

what I want is that on the FTP there is one folder in root called VOW.
This VOW folder again contains 3 folders called
1- Doc
2- Data
3- Photo
and these 3 folders contain files.

I want to copy them locally in the folder say D:\VOW in the same heirarchy. e.g. I'll get respective files in D:\VOW\Doc\, D:\VOW\Data\ and D:\VOW\Photo\.

Instead Im getting all the files from 3 folders to C:\Demo\bin\debug\. where my demo application exe is residing.

I hope U got the problem right.

Thanks in advance.
0 votes
by (162k points)
Supply the full path name of the file you want written locallly.

Hi,

Thanks. I know it is not that difficult programatically. Im able to get all files recursively.but they get downloaded in the directory where the exe resides and not in the my own defined direcory.

that's why I needed a way to specify full local path.
Can U pls guide me in that
0 votes
by
I know what he's talking about. I posted a reply on another topic like this. No matter what local path you give it, you get an access denied error.

Brian
0 votes
by
Doh!!

localpath = <folder name>\<file name>

If you use a folder name only, without the local file name, you get the access denied error.

Brian

Categories

...