VB.NET-Quellcode
- Public Class Form1
- Private Property AktuelleZeitString As String
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- Dim Chatroom As String = Me.TextBox1.Text
- Try
- 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)
- Dim ChatProtokoll As String = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\chat-ordner\" & Chatroom & ".txt")
- Me.TextBoxProtokoll.Text = ChatProtokoll
- Catch
- End Try
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim Chatroom As String = Me.TextBox1.Text
- Try
- Dim Nachricht As String = AktuelleZeit() & " _ " & Me.TextBoxName.Text & ": " & Me.TextBoxNachricht.Text
- Dim ChatProtokoll As String
- Try
- ChatProtokoll = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\chat-ordner\" & Chatroom & ".txt")
- Catch
- ChatProtokoll = ""
- End Try
- Dim UploadString As String = ChatProtokoll & vbNewLine & Nachricht
- My.Computer.FileSystem.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\chat-ordner\" & Chatroom & "_upload.txt", UploadString, False)
- My.Computer.Network.UploadFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\chat-ordner\" & Chatroom & "_upload.txt", "ftp://killerclan2.ki.funpic.de/chat01.txt", "Benutzer", "PW")
- Catch
- End Try
- End Sub
- Private Function AktuelleZeit()
- Dim AktuelleZeitString As String
- AktuelleZeitString = Now.Day & "." & Now.Month & "." & Now.Year & "." & Now.Hour & "." & Now.Second
- Return AktuelleZeitString
- End Function
- Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- If Me.Button2.Text = "Beitreten" Then
- Me.Button2.Text = "Verlassen"
- Me.Button1.Enabled = True
- Me.Timer1.Enabled = True
- Me.TextBox1.Enabled = False
- Me.Timer2.Enabled = True
- 'BETRETEN
- Else
- Me.Button2.Text = "Betreten"
- Me.Button1.Enabled = False
- Me.Timer1.Enabled = False
- Me.TextBox1.Enabled = True
- Me.Timer2.Enabled = False
- 'VERLASSEN
- End If
- End Sub
- Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
- PrivateNachricht.Show()
- End Sub
- Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
- Dim Name As String = Me.TextBoxName.Text
- 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)
- Dim Message As String = My.Computer.FileSystem.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "user_message/" & Name & ".txt")
- Dim TMP() As String = Split(Message, " _ ")
- Dim AktuelleZeit As String = TMP(0)
- Dim TMP2() As String = Split(TMP(1), ": ")
- Dim AbsenderName As String = TMP2(0)
- Message = Message.Replace(AktuelleZeit & " - " & Name & ": ", "")
- My.Computer.FileSystem.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "user_message/" & Name & ".txt", "", False)
- 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)
- MsgBox("Sie Haben um " & AktuelleZeit & " eine neue Nachricht von " & Name & " erhalten:" & vbNewLine & Message, vbInformation, "Sie haben eine Nachricht erhalten")
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- PrivateNachricht.Show()
- End Sub
- End Class
VB.NET-Quellcode
- Public Class PrivateNachricht
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim Name As String = Me.TextBox1.Text
- Dim Message As String = Me.TextBox2.Text
- Dim Messagestring As String = AktuelleZeit() & " - " & Name & ": " & Message
- My.Computer.FileSystem.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "/user_message/" & Name & "_upload.txt", Messagestring, False)
- 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)
- End Sub
- Private Function AktuelleZeit()
- Dim AktuelleZeitString As String
- AktuelleZeitString = Now.Day & "." & Now.Month & "." & Now.Year & "." & Now.Hour & "." & Now.Second
- Return AktuelleZeitString
- End Function
- 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? ps benutzer und passwort is ausgetauscht
lg