 |
|
 |
Method is always doing a case-sensitive search which may cause lot of problems.
On my side I have fixed it by copy-pasting overloaded FindSubdirectory method (with "ignoreCase" parameter) and changed it to work for files.
So, something like this:
public FtpFile FindFile(string fileName, bool ignoreCase)
{
InitHashtable();
if (ignoreCase)
{
string upperCase = fileName.ToUpper();
foreach (string s in m_files.Keys)
{
if (s.ToUpper() == upperCase)
return (FtpFile)m_files[s];
}
return null;
}
else
return (FtpFile)m_files[fileName];
}
WBR, Dr.Benj
|
|
|
|
 |
|
 |
I have fixed it on my side by changing to this:
public void Rename(string newName)
{
this.Name = newName;
}
WBR, Dr.Benj
|
|
|
|
 |
|
 |
1. Get Directory failed
In the file of FtpDirectory.cs
In my case, When I get the directorys infomation from ftp site, I reviceved dir message like below:
Quote: drw-rw-rw- 1 user group 0 Dec 16 02:24 test
So, the code before I fixed this bug can't parse any file or directory at all in this case. I write another Regex showed below to fix this bug.
static Regex m_UnixListLineExpression3 = new Regex(@"(?<dir>[\-d])(?<permission>([\-r][\-w][\-xs]){3})\s+\d+\s+\w+\s+\w+\s+(?<size>\d+)\s+(?<timestamp>\w+\s+\d+\s+\d{2}:\d{2})\s+(?<name>.+)");
2.UpLoad File failed
In the testApp, the list item's Tag property of local File leaves null, and the upload method will check the list item's Tag property, if null, upload the file, but the FtpDirecotry.BeginPutFile method can't find the file because of lacking full path of this file, so I rewrite this part of code like below.
In the file of MainForm.FillLocalListView method:
foreach (string file in Directory.GetFiles(path))
{
FileInfo fi = new FileInfo(file);
item = new ListViewItem(new String[2] { fi.Name, fi.Length.ToString() }, 1);
item.Tag = fi.FullName;
listViewLocal.Items.Add(item);
}
In the file of FtpDiretory of BeginPutFile method:
FileInfo fi = new FileInfo(localFile);
if (remoteFile == null)
remoteFile = fi.Name;
3. On .net 2.0 framework, the operations to UI controls between threads is not allowed. the simplest mothed to avoid it is use the Control.CheckForIllegalCrossThreadCalls = false;
|
|
|
|
 |
|
 |
Hi
I was happy about your code. It seems to do what I want as simple at is possible.
I love your event handles and I like the listening of files and folders as IEnumerable.
Please, help me to find a good Expression for the following 4 folders. At the moment only last 2 are listet with default expression and I cannot catch the right one.
"drwxr-xr-x 1 ftp ftp 0 Nov 16 11:21 AAA"
"drwxr-xr-x 1 ftp ftp 0 Nov 16 10:24 Aktuelle Staffel"
"drwxr-xr-x 1 ftp ftp 0 Sep 16 2011 Diverses"
"drwxr-xr-x 1 ftp ftp 0 Sep 16 2011 Vergangene Staffeln"
DateTime format seems to return different in first both folders (I don't know why) and needs any change to the Regex:
static Regex m_UnixListLineExpression = new Regex(@"(?<dir>[\-d])(?<permission>([\-r][\-w][\-xs]){3})\s+\d+\s+\w+\s+\w+\s+(?<size>\d+)\s+(?<timestamp>\w+\s+\d+\s+\d{4})\s+(?<name>.+)");
Regards
|
|
|
|
 |
|
 |
http://foren.activevb.de[^]
static Regex m_UnixListLineExpression01 = new Regex(@"(?<dir>[\-d])(?<permission>[\-r][\-w][\-xs]){3}\s+\d+\s+\w+\s+\w+\s+\d+\s+\w+\s+(?<size>\d+)(?<timestamp>\s+\d{2}:\d{2})\s+(?<name>.+)");
|
|
|
|
 |
|
 |
I couldn't "see" directories I'd just created because the timestamp group in the regex only looks for 4 digit year numbers.
Here is a before and after of a modified regex, line 59 in FtpDirectory.cs
static Regex m_UnixListLineExpression = new Regex(@"(?<dir>[\-d])(?<permission>([\-r][\-w][\-xs]){3})\s+\d+\s+\w+\s+\w+\s+(?<size>\d+)\s+(?<timestamp>\w+\s+\d+\s+(\d{4}|\d{2}\:\d{2}))\s+(?<name>.+)");
Now I can see all directories!
|
|
|
|
 |
|
 |
when i try to upload a link.txt file it's give me error that could not find link.txt
Object tag =listViewLocal.SelectedItems[0].Tag;
tag=null;
|
|
|
|
 |
|
 |
the code you have given over here does not mention the very basics of the procedure for me to start building the application for transferring file from one pc to another .
my task right now is to create a way to enable transfer of file b/w two computers using ftp
|
|
|
|
 |
|
 |
When i try to enumerate directories of the ftp server by using CurrentDirectory.SubDirectories
it does not show any directory. but I can easily list the files in the root directory.
Please help.
Thank You
modified on Wednesday, December 17, 2008 12:30 AM
|
|
|
|
 |
|
 |
Hi Alex,
It is fabulous code i found for ftp download...
my file downloading is working fine.. But i want to know how i can download files with folder structure...
I mean download folder tree..
Thanks In Advance
Parikshit
|
|
|
|
 |
|
 |
Hello
If you search a comfortable and reusable FTP client,
-- which is running on .NET Framework 1.1 or higher,
-- which can automatically put together splitted files on the server,
-- which allows to download only a part of a file on the server,
-- which allows to resume any broken download,
-- which automatically starts a separate thread,
-- which can be aborted any time from your main thread,
-- which supports UTF8 encoded filenames,
-- which has a built-in download scheduler,
-- which has a built-in bandwidth control,
-- which has a built-in preview function for the download of movies,
-- which automatically reconnects the server after an error has occurred,
-- which displays download progress in percent and in bytes and the remaining time,
-- which writes a detailed logging for all operations it does,
-- which is based on Wininet.dll and has one workaround for each of the 4 known Wininet.dll bugs,
-- which is very well tested and bug-free,
-- which is written by a very experienced programmer and has a very clean and well documented sourcecode,
then have a look at this project:
ElmueSoft Partial FTP Downloader[^]
Elmü
|
|
|
|
 |
|
 |
my server which i must to connect is "xxx.xxx.xxx.xxx\folder", and i can not use
----
Session.Server = "xxx.xxx.xxx.xxx\folder";
Session.Connect(username, password);
----
Exception is "No such host is know"
Please help me...thanks for advance
prayoon
|
|
|
|
 |
|
 |
A folder isn't part of a server's address, it's a resource on a server.
Connect to xxx.xxx.xxx.xxx then change directory to "folder"
|
|
|
|
 |
|
 |
Hi
Great job, I'm just curious how can I create directory
Thx 4 help
Andrew
|
|
|
|
 |
|
 |
Ok
I found solution
http://www.nsftools.com/tips/RawFTP.htm#MKD
internal void MKDIR(string dirname)
{
FtpCommand("MKD " + dirname);
if (m_lastResponse.Code != 257)
throw new FtpException("Cannot create !!! directory. + Error Code" + m_lastResponse.Code.ToString(), m_lastResponse);
...
}
|
|
|
|
 |
|
 |
session.ControlChannel.FtpCommand("mkd " + DirName);
|
|
|
|
 |
|
 |
Very useful tool but i cant get the parent directory as it is always null. Can you help please?
|
|
|
|
 |
|
 |
I want to move a existing file from one folder to another folder in FTP.Can any body give logic or atleast suggestions.
Chandu.Sanka
|
|
|
|
 |
|
 |
Hi
i am downloading a file from ftp programitically in ASP.NET using c#.and i am unable to trace the target directory in which the file is stored
i want to trace the target location directory where the file is downloaded.
chandu.sanka
|
|
|
|
 |
|
 |
Hello,
It seems to be a great project ! Congratulations !
But in the testApplication, kcommon.dll is required and I don't find it.
Could you tell me how to proceed in order to download it ot to make it ?
If I build the kcommon project, I've got an error on
[assembly: AssemblyVersion("1.0.*.*")]
AssemblyInfo.cs(31): Error emitting 'System.Reflection.AssemblyVersionAttribute' attribute -- 'The version specified '1.0.*.*' is invalid'
and
private Session ftpSession;
MainForm.cs(17): The type or namespace name 'Session' could not be found (are you missing a using directive or an assembly reference?)
Thanks for your help.
|
|
|
|
 |
|
 |
OK I have found an answer in another post :
======================================
Re: Error trying to build
[Click for User Profile] Alex Kwok 0:18 2 Jun '02
Oh sorry, it's my mistake.
Change 1.0.*.* to 1.0.* will solve the error.
[Reply | Email | View Thread | Get Link] Rate this message: 1 2 3 4 5 (out of 5)
Report as Spam or Abuse
======================================
Good job !
Bye
|
|
|
|
 |
|
 |
Hellooo
I have an Error:
Error 1 The type or namespace name 'KCommon' could not be found (are you missing a using directive or an assembly reference?
Do you have this dll file?
Tank you.
Best Regards
|
|
|
|
 |
|
 |
i want to download a zip file from FTP server using Visual Studio 2003 in ASP.NET.
Kindly help
regards
Raju sharma
|
|
|
|
 |
|
 |
I m trying to upload a file into ftp.It gives msg "Could not find File name'xyz.txt'". Can u suggest what changes i have to make if file doen not exist in ftp server. So as to upload new files into it.
regards,
preet
|
|
|
|
 |
|
 |
Thanks Alex - The class is fantastic for newbies like me.
This may sound a little stupid, i hope someone can help.
I have a loop here which look throught all directory in the remote server then copy the file via FTP to local PC, and then once copied the loop will make a copy of itself with a different name in the remote server. The code looks like this, I can get it to FTP but not copy itself in the remote server, I guess i have problem understanding how steams works on the remote server.
foreach(FtpFile f in d.Files)
{
//this line downloads the file to localPC
d.GetFile(f.Name.ToString());
ReadStream1 = f.GetOutputStream();
WriteStream1 = ftpSession.CurrentDirectory.CreateFileStream
(f.Name.ToString()+".BU");
while ((readed=ReadStream1.Read(buff, 0, 4096))!=0)
WriteStream1.Write(buff, 0, readed);
ReadStream1.Close();
WriteStream1.Close();
}
Can some advise what the problem is?
Many Thanks
Best Regards
Jason
Life is a search.
|
|
|
|
 |