WebClient Upload, FileAlreadyInUse (Aber das ist sie eigentlich nicht...) [FTP]

  • VB.NET

    WebClient Upload, FileAlreadyInUse (Aber das ist sie eigentlich nicht...) [FTP]

    Hallo :)

    Ich habe da ein kleines Problem mit meinem Webclient :/
    Ich möchte also eine datei Hochladen aber er sagt mir ein anderer Process würde auf die Datei zugreifen (was nicht stimmt).

    Hier ist mein code:

    Imports:

    VB.NET-Quellcode

    1. Imports System.Net
    2. Imports System.IO


    Die Funktion mit dem Fehler:

    VB.NET-Quellcode

    1. Public Shared Function UploadFile(ByVal username As String, ByVal stringtoupload As String, ByVal server As String, ByVal user As String, ByVal pass As String) As Boolean
    2. Using wc As New Net.WebClient
    3. wc.Credentials = New Net.NetworkCredential(username, pass)
    4. Dim uri As String = server & "/" & My.Settings.nickname & ".txt"
    5. MsgBox(uri)
    6. Try
    7. MsgBox("1")
    8. 'Dim fs As FileStream = File.Create(Application.StartupPath & "" & My.Settings.nickname & ".txt")
    9. 'fs.Close()
    10. 'fs.Dispose()
    11. MsgBox("2")
    12. wc.UploadFile(Application.StartupPath & "" & My.Settings.nickname & ".txt", My.Settings.nickname & ".txt")
    13. 'MsgBox(Application.StartupPath & "" & My.Settings.nickname & ".txt")
    14. wc.UploadStringAsync(New Uri(uri),stringtoupload)
    15. wc.Dispose()
    16. Return True
    17. Catch ex As Exception
    18. MsgBox("ERROR" & Environment.NewLine & ex.Message)
    19. Return False
    20. End Try
    21. End Using
    22. End Function


    Ich habe absolut keine Ahnung wo der Fehler liegt :/
    Noch lieber wäre es mir wenn ich die Datei einfach auf dem FTP erstellen kann, weil

    VB.NET-Quellcode

    1. wc.UploadString

    erstellt keine Datei bei mir.

    Danke für Hilfe
    Dustin~

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Hansbald“ ()