 |
|
 |
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.
|
|
|
|
 |
|
 |
It looks like you are simply overwriting the downloaded file into the current directory on the FTP server. Change your directory then write the stream back.
|
|
|
|
 |
|
 |
Great component Alex - awesome work!! I noticed that the UNIX regex's were failing to recognise some files and directories that were returned by the FTP server, specifically the following patterns weren't being matched in MatchingListLine() -rw-r--r-- 1 500 500 251805 May 3 16:53 filename.txt drwxr-xr-x 7 root root 4096 Apr 11 15:47 dirname
Here's the fix - in FtpDirectory change implement the following 4 regex's: #region Regular expression to parse list lines static Regex m_UnixListLineExpression1 = 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>.+)"); static Regex m_UnixListLineExpression2 = 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>.+)"); static Regex m_UnixListLineExpression3 = new Regex(@"(?<dir>[\-d])(?<permission>([\-r][\-w][\-xs]){3})\s+\d+\s+\d+\s+(?<size>\d+)\s+(?<timestamp>\w+\s+\d+\s+\d{4})\s+(?<name>.+)"); static Regex m_UnixListLineExpression4 = new Regex(@"(?<dir>[\-d])(?<permission>([\-r][\-w][\-xs]){3})\s+\d+\s+\d+\s+(?<size>\d+)\s+(?<timestamp>\w+\s+\d+\s+\d{2}:\d{2})\s+(?<name>.+)"); static Regex m_DosListLineExpression = new Regex(@"(?<timestamp>\d{2}\-\d{2}\-\d{2}\s+\d{2}:\d{2}[Aa|Pp][mM])\s+(?<dir>\<\w+\>){0,1}(?<size>\d+){0,1}\s+(?<name>.+)"); #endregion
... and modify MatchingListLine as follows: private Match MatchingListLine(string line) { Match m = m_UnixListLineExpression1.Match(line); if(m.Success) return m; m = m_UnixListLineExpression2.Match(line); if(m.Success) return m; m = m_UnixListLineExpression3.Match(line); if(m.Success) return m; m = m_UnixListLineExpression4.Match(line); if(m.Success) return m; m = m_DosListLineExpression.Match(line); if(m.Success) return m; return null; }
Also, the working directory after logging in to an FTP server may not be the user's root - it may be possible to navigate up past it. The following code change allows the user to do this using FtpDirectory.Parent public FtpDirectory Parent { get { CheckSessionCurrentDirectory(); //if(m_fullPath == m_session.RootDirectory.m_fullPath) // return null; if(m_fullPath == "/") return null; <...snip...> return parent; } } Thanks
|
|
|
|
 |
|
 |
Hello. My english is not very good but i ll try to be clear.
I found Kcommon.dll very useful and i need it to create a vb .NET application.
My programmin skills are not the best.
So i faced the problem with directory listing... Not all files and directories are listed. I try connection to linux boxes.
I downloaded the code but i dont know how to change this and recompile to .NET dll file so to use it to my application...
Could you help me / give me clear instructions...
I would appreciate a lot your offer.
Thanks.
|
|
|
|
 |
|
 |
Hi -
i have the same Problem too in a Vb.Net Scenario....
i hope for Tips too.
|
|
|
|
 |
|
 |
Another pattern for unix like directory listing:
To match this:
-rwxrwxrwx 1 owner group 991 Oct 28 13:59 file_name.txt
use this:
(?<dir>[\-d])(?<permission>([\-r][\-w][\-xs]){3})\s+\d+\s+\w+\s+\w+\s+(?<size>\d+)\s+(?<timestamp>\w+\s+\d+\s+\d{1,2}\:\d{1,2})\s+(?<name>.+)
This is specially useful for Windows FTP Server which have Unix directory listing activated.
|
|
|
|
 |
|
 |
Is RegEx best way to parse this? I'm using a custom parser for this.
I can donate some unit tests if anyone wants.
Here's the commercial .NET FTP component that supports all formats returned by the servers.
|
|
|
|
 |
|
 |
I am trying to use this library in my vb.net application.
My Code is as follow:
Private Sub Form_Load()
Private ftpsession As New Session
Dim files As String
Dim count As Integer
Dim rootdir As FtpDirectory
ftpsession.Server = "000.00.0.00"
ftpsession.Connect("User1", "test")
ftpsession.ChangeDirectory("Folder1")
rootdir = ftpsession.CurrentDirectory
count = rootdir.Files.Count
For Each file As FtpFile In ftpsession.CurrentDirectory.Files
files += file.Name & " - "
Next
Label1.Text += " Folder : " & rootdir.Name
Label1.Text += " >> Files : " & files & "----------- || "
End Sub
I already insert the function "ChangeDirectory()" in FTPSession.cs Class
like this..
public bool ChangeDirectory(string Pathname)
{
try
{
m_state.ControlChannel.CWD(Pathname);
m_state.CurrentDirectory.ForceCWDUpdate();
FtpDirectory fDir = new FtpDirectory((SessionConnected)m_state);
m_state.CurrentDirectory = fDir;
m_state.CurrentDirectory.InitHashtable();
return true;
}
catch (Exception e)
{
return false;
}
}
And also already copyed the following function in FTPDirectory.cs Class.
public void ForceCWDUpdate()
{
m_fullPath = m_session.ControlChannel.PWD();
if(m_fullPath == "/")
{
m_name = m_fullPath;
return;
}
string[] directories = m_fullPath.Split('/');
m_name = directories[directories.Length-1];
m_fullPath += "/";
}
And write these following lines in "MatchingListLine" Function in the FTPDirectory.cs Class
m = m_UnixListLineExpression3.Match(line);
if(m.Success)
return m;
My program can get files from the currentdirectory when I trying to connect to the FTP server within our LAN.
But I cannot connect to the the other FTP server over the Internet.
I break at this line:
f = ftpsession.ChangeDirectory("TEST1")
At that time :
?ftpsession.IsConnected
True
?ftpsession.RootDirectory.Files.Count
Run-time exception thrown : KCommon.Net.FTP.FtpException - Failed to open data connecton.
What I need to change?
Any Idea? Please help me. I am in a tough situation.
Thansks..
Star9999
-- modified at 23:04 Thursday 20th April, 2006
|
|
|
|
 |
|
 |
I am trying to change the directory and using the following code
ftpSession.CurrentDirectory = ftpSession.CurrentDirectory.FindSubdirectory("somedir");
It works fine if the somedir is a normal dir but in my case it is a virtual folder and I am getting an error there.
Is there any other way to change the directory.
Thanks
coder
|
|
|
|
 |
|
 |
Read my posting about the directory timestamp regex. Not sure, but it might fix your problem.
|
|
|
|
 |
|
 |
Hi,
I am very interested in this. ButHow come i can't download the demo file?
Thanks.
Henson
|
|
|
|
 |
|
 |
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.
Good Work..
Happy Coding
"San"
|
|
|
|
 |
|
 |
I'm rookie programmer, and I try to code FTP by VB.NET.
And I have some problem in GetFile From FTP follow this code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ServFile As String = "TEST.ini"
Dim ServName As String = "192.168.1.148"
Dim User As String = "Test"
Dim Pass As String = "Test"
Try
mftp = New KCommon.Net.FTP.Session
mftp.Server = (ServName)
mftp.Port = 21
mftp.Connect(ServUser, ServPass)
mftp.CurrentDirectory.CreateFile("b.txt") ' Work
mftp.CurrentDirectory.PutFile("c.txt") 'Work
mftp.CurrentDirectory.BeginGetFile(ServFile)
' It not Work and have message
' "ex.Message"Remote file (TEST.ini) not found. ' Try refresh the directory." String"
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Thanks a lot for Ur Help.
|
|
|
|
 |
|
 |
try something like :
FtpFile RemoteFile = mftp.CurrentDirectory.FindFile(ServFile);
if (RemoteFile != null) {
FtpInpuDataSream Stream = RemoteFile.GetInputStream()
}
or :
mftp.CurrentDirectory.Refresh() //--- so it reads the remote directory
mftp.CurrentDirectory.BeginGetFile(ServFile);
and perhaps it works in combination of both :
mftp.CurrentDirectory.FindFile(ServFile);
mftp.CurrentDirectory.BeginGetFile(ServFile)
good luck
pascal
|
|
|
|
 |
|
 |
ReadAppendChar will block in s.read (::response.cs) if there isn't anything incomming from remote server, so your thread hangs and isn't interruptible (thread.abort() has no effect - no idea, why). so i wrote this fix to have a timeout (set the time as needed! by yourself). <code> private char ReadAppendChar(Stream s, ref System.Text.StringBuilder Text) { try { byte[] Buffer = new byte[1]; IAsyncResult Result = s.BeginRead(Buffer, 0, Buffer.Length, null, null); Result.AsyncWaitHandle.WaitOne(500, false); if (s.EndRead(Result) > 0) { char Sign = (char)Buffer[0]; Text.Append(Sign); return Sign; } else { throw new Exception("timeout"); } } catch (Exception ex) { throw ex; } } </code> greetings! pascal /* no comment */
|
|
|
|
 |
|
 |
In fact this problem occurs fairly frequently. It is a race condition that happens when the server outputs two responses directly after each other. This happens especially often with the list command, where the server outputs the list, and then the "OK" message.
Because of the way the stream reader works, it reads ahead in the stream. When you call the constructor for the FTPResponse, you create a new stream reader, and thus discards the old one. This is a serious problem since the previous stream reader has already buffered the data. The new stream reader will block forever, since there is no more data.
The solution is to use just one stream reader, and pass that to the FTPResponse constructor.
Another bug in the FTPResponse reader, is that it cannot parse multiline responses:
220 OK - Features:
MDTM
XFR
220-OK
It will try to parse the number in each line, and throw an exception when parsing line 2. It is a fairly small fix. Other than that, actually a really nice component.
|
|
|
|
 |
|
 |
Could any one help us how to read the xml file and rename the file present in the ftp server through c# programming langaugae.
|
|
|
|
 |
|
 |
there are unhandled exceptions while opening a stream with :
Stream stream = m_connection.GetStream();
on several places in your code been thrown, if the socket is not connected.
(i just wanted to see whats happening if i unplugg my networkcard
greetings
daniel
/* no comment */
|
|
|
|
 |
|
 |
hi i'm not shure, if i have the most up to date version of your lib (1.0.0.0) but i found a problem while parsing the lines received from a linux ftp server. therefore i wrote 2 additional expressions to make it work. problematical lines have been : (1) drwxr-xr-x 7 daniel daniel 4096 2005-02-19 23:55 docs -rw-r--r-- 1 daniel daniel 0 2005-07-25 13:58 text.txt lrwxrwxrwx 1 root root 13 2005-02-18 17:56 K20ssh -> ../init.d/ssh and (2) drwxr-xr-x 1 501 501 4096 Mar 29 08:16 archive drwxrwxrwx 1 owner group 0 Jul 20 14:10 in my expression are for this : static Regex m_LinuxListLineExpression1 = new Regex(@"^((?<dir>[\-ld])(?<permission>([\-r][\-w][\-xs]){3})\s+(?<filecode>\d+)\s+(?<owner>\w+)\s+(?<group>\w+)\s+(?<size>\d+)\s+(?<timestamp>(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})\s+(?<hour>\d?\d) <minute>\d{2}))\s+(?<name>\w.+))$"); static Regex m_LinuxListLineExpression2 = new Regex(@"^((?<dir>[\-ld])(?<permission>([\-r][\-w][\-xs]){3})\s+(?<filecode>\d+)\s+(?<owner>\w+)\s+(?<group>\w+)\s+(?<size>\d+)\s+(?<timestamp>(?<month>[a-z|A-Z]{3})\s+(?<day>(\d?\d))\s+(?<hour>\d?\d) <minute>\d{2}))\s+(?<name>\w.+))$"); so also links are detected and after changing the condition to detect the directory (adding dir.ToLower() != "") everything works fine. thanks a lot for your great library! greetings! daniel adam (daniel(at)binaervarianz(dot)de) /* no comment */
|
|
|
|
 |
|
 |
This fixed my problem. Thanks!
Just a note in case it is not perfectly clear to somebody who needs to do this patch goes in the code in FtpDirectory.cs with the other regular expressions.
And This code goes in the function private Match MatchingListline(string line)
m = m_LinuxListLineExpression1.Match(line);
if(m.Success)
return m;
m = m_LinuxListLineExpression2.Match(line);
if(m.Success)
return m;
|
|
|
|
 |
|
 |
can any one suggest with full codeor any idea how to upload and download files or folders or images using files is asp.net to FTP
|
|
|
|
 |