
a_jam_sandwich
Avatar/Signature-
Posts
371 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by a_jam_sandwich
-
The error will occur when you have an object that has no instance (Not created) i.e. is a reference What execlty is the section of code that has the problem Andy
-
Freaky? Im making a class for get info from halflife servers using a udp socket. the strange thing is I have sent the command to the server format of ÿÿÿÿinfo The problem is converting this into bytes to send over the net causes a strange problem I would expect the first byte to be the number 255 except is not its 63 sending the packet works but im in an endless loop waiting for a response. If I change the first 4 bytes to 255 manually there isn't a problem and I get a response. Any ideas as im baffeled or being stupid Andy
-
Heres how to format dates in C# System.DateTime.Now.ToString("dd/MM/yyyy"); You can format on the ToString method. Using your method DateTime StartDate; StartDate = DateTime.Parse(textBox1.Text).Date; whatever = DateTime.ToString("dd/MM/yyyy") Andy
-
You have to remove the tabpage from the tabcontrol see example ' Remove the tabpage TabControl1.TabPages.Remove(TabPage1) ' Add the tabpage back again TabControl1.TabPages.Add(TabPage1) Andy
-
Thank you greatly appreciated
-
Well apart from the above ... and the above only seams to happen on one ftp server strange :? anyway find attached a usable version on the control with a small client also wrote to see how to use it anyway its fairly simple to use you can download/upload a file just using 6 lines of code for example Dim MyFTP As New classFTP If MyFTP.Connect("ftp.microsoft.com", "anonymouse", "test@test.com", "reskit/win2000") Then MyFTP.DownloadFile("now.zip", "now.zip") Else MsgBox("Could not connect", MsgBoxStyle.Information, "Error Connecting") End If Anyway please feel free to change/modify it. If this control helps please tell me. Andy p.s I know there are some bugs in getting the Directory listings from a couple of severs I am working on this. ftp.zip
-
Doesn't anyone know? Andy
-
I have a problem with receiving files on a socket for some reason hopefully someone will know why. After connecting to a ftp sever I download files using the following code. Do BytesRemaining = PasvSocket.Receive(ReceiveBuffer, 512, SocketFlags.None) BytesReceived += BytesRemaining MyFile.Write(ReceiveBuffer, 0, BytesRemaining) RaiseEvent DownloadProgress(RemoteFilename, BytesReceived, FileSize) Application.DoEvents() Loop Until (BytesRemaining = 0) The problem is SOMETIMES not all the time when downloading files, the program will hang on the line BytesRemaining = PasvSocket.Receive(ReceiveBuffer, 512, SocketFlags.None) And the program will freeze waiting for PasvSocket to receive anything. This does not happen all the time and therefore I am completely baffeled. Any ideas? Many thanks Andy
-
Im putting a control together to do just that with be done soon Andy
-
Right this is what I have come up with so far it connects in pasv mode * Can display directory listing. * Can change directory * Can download files There are problem with phasing the directory listings on Unix but windows server seems ok there is timeouts for every response Have a look, it is still well in the alpha stage so don't exspect miricals but there is a demo proj file. Any one want to add to it to build it up be my guest Andy ftp.zip
-
Blooming hell this is a nightmare which is now comming together didn't think async was so bad lol will post control and source when done. BTW this is my first attemp at tcp using sockets so coding might be a bit weird Andy
-
I've setup an async receive now following code ... Public Function Response() As String Try Dim State As New classBuffer(512, MyFTPSocket) Dim ReceiveResult As IAsyncResult = MyFTPSocket.BeginReceive(State.Buffer, 0, State.BufferSize, 0, AddressOf ResponseCallback, State) ReceiveResult.AsyncWaitHandle.WaitOne(1, True) Return State.Response Catch ex As Exception Console.WriteLine(ex.ToString) End Try End Function Public Sub ResponseCallback(ByVal ar As IAsyncResult) Try Dim state As classBuffer = CType(ar.AsyncState, classBuffer) Dim Socket As Socket = state.Socket Dim BytesRead As Integer = Socket.EndReceive(ar) If BytesRead > 0 Then Console.WriteLine("-->" & Encoding.ASCII.GetString(state.Buffer, 0, BytesRead)) 'state.Response += Encoding.ASCII.GetString(state.Buffer, 0, BytesRead) Socket.BeginReceive(state.Buffer, 0, state.BufferSize, 0, AddressOf ResponseCallback, state) Else receiveDone.Set() End If Catch ex As Exception Console.WriteLine(ex.ToString) End Try End Sub The problem is ReceiveResult.AsyncWaitHandle.WaitOne(1, True) If I do not put a timeout on the thread it hangs forever probley because of this line Dim BytesRead As Integer = Socket.EndReceive(ar) Checking the help it says the above cause a stop indefinatly until data is received. It seams to me to be bad practice to rely on a timeout to stop the program from hanging? Has anyone got any ideas? Many thanks Andy P.s. Cheer so far PlausiblyDamp your comments are very usful
-
cheers I used the peek flag to see if anything was in the socket buffer there isn't I tried doing the same commands in telnet when connecting to the server and the same happens on telnet it doesn't return anything. Im thinking maybe I just need to understand the FTP protocol Andy
-
Now i have this Imports System.Net Imports System.Net.Sockets Imports System.IO Imports System.Text Imports System.Text.Encoding Module ModFTP Public Class classFTP Public LogWindow As TextBox Private MyFTPSocket As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) Public Function Connect() ConnectToHost() Response() Send("USER Anonymous") Response() Send("PASS [email]andrew_duff@btinternet.com[/email]") Response() Response() ListDirectory("") End Function Public Function RunCommand(ByVal Command As String) Send(Command) Response() End Function Private Function ConnectToHost() Dim MyHost As IPHostEntry = Dns.GetHostByName("ftp.microsoft.com") Dim MyEntry As New IPEndPoint(MyHost.AddressList(0), 21) MyFTPSocket.Connect(MyEntry) If Not LogWindow Is Nothing Then LogWindow.Text += "Connected to [" & MyHost.AddressList(0).ToString & "]" & vbCrLf End Function Public Function Send(ByVal Command As String) Try Dim SendBuffer As Byte() = ASCII.GetBytes(Command & Chr(13) & Chr(10)) MyFTPSocket.Send(SendBuffer, SendBuffer.Length, 0) Console.WriteLine("Command Sent") Catch ex As Exception End Try End Function Public Function Response() Try Dim ReceiveBuffer(8000) As Byte Dim BytesReceived As Integer = MyFTPSocket.Receive(ReceiveBuffer) Console.WriteLine(BytesReceived) If Not LogWindow Is Nothing Then LogWindow.Text += ASCII.GetString(ReceiveBuffer, 0, BytesReceived) Catch ex As Exception End Try End Function Public Function ListDirectory(ByVal Directory As String) Try Dim BytesReceived As Integer Dim ReponseServerString As String Dim ReceiveBuffer(512) As Byte RunCommand("LIST") 'Do ' BytesReceived = MyFTPSocket.Receive(ReceiveBuffer, 512, SocketFlags.Peek) ' ReponseServerString += Encoding.ASCII.GetString(ReceiveBuffer, 0, BytesReceived) 'Loop Until BytesReceived = 0 'If Not LogWindow Is Nothing Then LogWindow.Text += ReponseServerString Catch ex As Exception End Try End Function End Class End Module Problem is the directory listing falls over and dies any ideas thanks andy
-
Strange ??? not what i get. I changed it to use a socket instead and now it seams to work will post source soon
-
Not at all i know that will send that response the problem is the response is not being received
-
Well done well deserved Andy
-
Currently im trying to write an FTP class but have run into problems. The below code connects to the server and gets the welcome message after that nothing yarda :confused: so I have no idea see code below. Imports System.Net Imports System.Net.Sockets Imports System.Text.Encoding Module ModFTPClass Public Class classMyFTP Private _username As String = "anonymous" Private _password As String = "" Private _ip As String = "" Private _ISCONNECTED As Boolean = False Private FTP_Socket As New TcpClient Private FTP_networkStream As NetworkStream Public Event onError(ByVal ErrorMessage As String) Public Function Connect() As Boolean If OpenConnection() Then ReceiveCommand() SendCommand("USER " & _username) ReceiveCommand() SendCommand("PASS " & _password) ReceiveCommand() SendCommand("LS www") ReceiveCommand() End If End Function Private Function OpenConnection() As Boolean Try FTP_Socket.Connect("ftp.microsoft.com", 21) FTP_networkStream = FTP_Socket.GetStream() _ISCONNECTED = True Return True Catch ex As Exception RaiseEvent onError(ex.Message.ToString) Return False End Try End Function Private Function SendCommand(ByVal UserCommand As String) If _ISCONNECTED Then Dim MyCommand As Byte() = ASCII.GetBytes(UserCommand & vbCrLf) FTP_networkStream.Write(MyCommand, 0, MyCommand.Length) End If End Function Private Function ReceiveCommand() As String If _ISCONNECTED Then If FTP_networkStream.CanRead Then Dim MyCommand(1024) As Byte Dim BytesRead As Integer = 1 Dim ReceivedCommand As String Dim Starttime As Long = Environment.TickCount Do BytesRead = FTP_networkStream.Read(MyCommand, 0, 1024) Console.WriteLine(BytesRead) ReceivedCommand += ASCII.GetChars(MyCommand) Loop While FTP_networkStream.DataAvailable Console.WriteLine(ReceivedCommand) End If End If End Function End Class End Module If anyone can figuar this out that would be great Cheers Andy
-
I get exactly the same error
-
if you mean sharing an internet connection bandwidth then yes the programs call Linux and you can do capping traffic shapping etc Andy
-
Autonumber in SQL Server
a_jam_sandwich replied to PurpleMonkey's topic in Database / XML / Reporting
Yes it's called and Identity Andy -
Because asp.net is a server based language it will look at the server instead of the client PC. The work around it to upload the file to the server then import into the access database Andy
-
How can I write the text from a textbox in my database?
a_jam_sandwich replied to Zion's topic in ASP.NET
Have a look im my site there are some examples there not in asp.net but the methods are the same Andy -
Should work whats the code your using Andy
-
Microsoft Access Database with VB.NET
a_jam_sandwich replied to imwork2003's topic in Database / XML / Reporting
Look at my site you will find stuff on simple ado.net using access there Andy