FTP Chat

  • VB.NET

Es gibt 4 Antworten in diesem Thema. Der letzte Beitrag () ist von Manschula.

    VB.NET-Quellcode

    1. Public Class Form1
    2. Private Property AktuelleZeitString As String
    3. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    4. Dim Chatroom As String = Me.TextBox1.Text
    5. Try
    6. My.Computer.Network.DownloadFile("ftp://killerclan2.ki.funpic.de/" & Chatroom & ".txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\chat-ordner\" & Chatroom & ".txt", "Benutzer", "PW", False, 60000, True)
    7. Dim ChatProtokoll As String = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\chat-ordner\" & Chatroom & ".txt")
    8. Me.TextBoxProtokoll.Text = ChatProtokoll
    9. Catch
    10. End Try
    11. End Sub
    12. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    13. Dim Chatroom As String = Me.TextBox1.Text
    14. Try
    15. Dim Nachricht As String = AktuelleZeit() & " _ " & Me.TextBoxName.Text & ": " & Me.TextBoxNachricht.Text
    16. Dim ChatProtokoll As String
    17. Try
    18. ChatProtokoll = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\chat-ordner\" & Chatroom & ".txt")
    19. Catch
    20. ChatProtokoll = ""
    21. End Try
    22. Dim UploadString As String = ChatProtokoll & vbNewLine & Nachricht
    23. My.Computer.FileSystem.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\chat-ordner\" & Chatroom & "_upload.txt", UploadString, False)
    24. My.Computer.Network.UploadFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\chat-ordner\" & Chatroom & "_upload.txt", "ftp://killerclan2.ki.funpic.de/chat01.txt", "Benutzer", "PW")
    25. Catch
    26. End Try
    27. End Sub
    28. Private Function AktuelleZeit()
    29. Dim AktuelleZeitString As String
    30. AktuelleZeitString = Now.Day & "." & Now.Month & "." & Now.Year & "." & Now.Hour & "." & Now.Second
    31. Return AktuelleZeitString
    32. End Function
    33. Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
    34. End Sub
    35. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    36. If Me.Button2.Text = "Beitreten" Then
    37. Me.Button2.Text = "Verlassen"
    38. Me.Button1.Enabled = True
    39. Me.Timer1.Enabled = True
    40. Me.TextBox1.Enabled = False
    41. Me.Timer2.Enabled = True
    42. 'BETRETEN
    43. Else
    44. Me.Button2.Text = "Betreten"
    45. Me.Button1.Enabled = False
    46. Me.Timer1.Enabled = False
    47. Me.TextBox1.Enabled = True
    48. Me.Timer2.Enabled = False
    49. 'VERLASSEN
    50. End If
    51. End Sub
    52. Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
    53. PrivateNachricht.Show()
    54. End Sub
    55. Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
    56. Dim Name As String = Me.TextBoxName.Text
    57. My.Computer.Network.DownloadFile("ftp://killerclan2.ki.funpic.de/" & Name & ".txt", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "user_message/" & Name & ".txt", "Benutzer", "PW", False, 60000, True)
    58. Dim Message As String = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "user_message/" & Name & ".txt")
    59. Dim TMP() As String = Split(Message, " _ ")
    60. Dim AktuelleZeit As String = TMP(0)
    61. Dim TMP2() As String = Split(TMP(1), ": ")
    62. Dim AbsenderName As String = TMP2(0)
    63. Message = Message.Replace(AktuelleZeit & " - " & Name & ": ", "")
    64. My.Computer.FileSystem.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "user_message/" & Name & ".txt", "", False)
    65. My.Computer.Network.UploadFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "user_message/" & Name & ".txt", "ftp://killerclan2.ki.funpic.de/user_message/" & Name & ".txt", "benutzer", "PW", False, 60000)
    66. MsgBox("Sie Haben um " & AktuelleZeit & " eine neue Nachricht von " & Name & " erhalten:" & vbNewLine & Message, vbInformation, "Sie haben eine Nachricht erhalten")
    67. End Sub
    68. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    69. PrivateNachricht.Show()
    70. End Sub
    71. End Class


    VB.NET-Quellcode

    1. Public Class PrivateNachricht
    2. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    3. Dim Name As String = Me.TextBox1.Text
    4. Dim Message As String = Me.TextBox2.Text
    5. Dim Messagestring As String = AktuelleZeit() & " - " & Name & ": " & Message
    6. My.Computer.FileSystem.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "/user_message/" & Name & "_upload.txt", Messagestring, False)
    7. My.Computer.Network.UploadFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "/user_message/" & Name & "_upload.txt", "ftp://killerclan2.ki.funpic.de/user message/" & Name & ".txt", "Benutzer", "PW", False, 60000)
    8. End Sub
    9. Private Function AktuelleZeit()
    10. Dim AktuelleZeitString As String
    11. AktuelleZeitString = Now.Day & "." & Now.Month & "." & Now.Year & "." & Now.Hour & "." & Now.Second
    12. Return AktuelleZeitString
    13. End Function
    14. End Class


    VB zeigt 0 fehler an dan wen ichs teste bekomme ich den fehler >>> System.Net.WebException wurde nicht behandelt.
    Message=Der Remoteserver hat einen Fehler zurückgegeben: (550) Datei nicht verfügbar (z.B. nicht gefunden oder kein Zugriff).
    Source=System
    StackTrace:
    bei System.Net.WebClient.DownloadFile(Uri address, String fileName)
    bei Microsoft.VisualBasic.MyServices.Internal.WebClientCopy.DownloadFile(Uri address, String destinationFileName)
    bei Microsoft.VisualBasic.Devices.Network.DownloadFile(Uri address, String destinationFileName, ICredentials networkCredentials, Boolean showUI, Int32 connectionTimeout, Boolean overwrite, UICancelOption onUserCancel)
    bei Microsoft.VisualBasic.Devices.Network.DownloadFile(String address, String destinationFileName, String userName, String password, Boolean showUI, Int32 connectionTimeout, Boolean overwrite, UICancelOption onUserCancel)
    bei Microsoft.VisualBasic.Devices.Network.DownloadFile(String address, String destinationFileName, String userName, String password, Boolean showUI, Int32 connectionTimeout, Boolean overwrite)
    bei WindowsApplication1.Form1.Timer2_Tick(Object sender, EventArgs e) in C:\Users\h752\Documents\Visual Studio 2010\Templates\ftp chat.vb:Zeile 69.
    bei System.Windows.Forms.Timer.OnTick(EventArgs e)
    bei System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
    bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
    bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
    bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
    bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
    bei WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:Zeile 81.
    bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
    bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    bei System.Threading.ThreadHelper.ThreadStart()
    InnerException:

    was mach ich falsch? :cursing: ps benutzer und passwort is ausgetauscht

    lg