Resolved Just Stuck With Something Simple

John_Oneill

New member
Joined
Mar 8, 2012
Messages
1
Programming Experience
Beginner
*EDIT* issue was fixed, sorry.

Hello, Basiclly It's Simple But Im Stuck With This Bit Of Code.

Imports System.NetImports System.IO


Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        test()
    End Sub
    Private Sub test()
        Dim file As String = "C:\Users\" & System.Environment.UserName & "\Pictures\check.txt"
        Dim filen As String = "john.txt"
        Dim ftps As String = "ftp://take0000.comuv.com/public_html/"
        Dim user As String = "a7106351"
        Dim pass As String = "026594"
        My.Computer.Network.UploadFile(file, ftps & filen, user, pass)
    End Sub
End Class


The Error Is The My.Computer.Network Command And Basiclly Its Saying It Needs The Address + Name Of File. But It's That Correct.

Thanks John
 
Last edited:
G'd evening,
I'm glad you find a solution. I think that you should remove the information to log in to your ftp. Not for people from here but just to avoid unexpected visitors.
G'd Luck
 
*EDIT* issue was fixed, sorry.

Hello, Basiclly It's Simple But Im Stuck With This Bit Of Code.

Imports System.NetImports System.IO


Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        test()
    End Sub
    Private Sub test()
        Dim file As String = "C:\Users\" & System.Environment.UserName & "\Pictures\check.txt"
        Dim filen As String = "john.txt"
        Dim ftps As String = "ftp://take0000.comuv.com/public_html/"
        Dim user As String = "a7106351"
        Dim pass As String = "026594"
        My.Computer.Network.UploadFile(file, ftps & filen, user, pass)
    End Sub
End Class


The Error Is The My.Computer.Network Command And Basiclly Its Saying It Needs The Address + Name Of File. But It's That Correct.

Thanks John
John,
You do know that the pictures folder in Vista/7 is 'My Pictures' right? Your code is currently looking for a directory 'Pictures' inside there profile, which by default would not be a correct path, unless they have changed it in their windows account. In any event, you can grab the correct path even if the user has their account pointing to a pictures folder outside of their profile (even another drive) by using:

Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)


which will return the current user's pictures folder where ever it may be.

So you would do:
Dim file As String = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "check.txt")
 
John,
You do know that the pictures folder in Vista/7 is 'My Pictures' right? Your code is currently looking for a directory 'Pictures' inside there profile, which by default would not be a correct path, unless they have changed it in their windows account. In any event, you can grab the correct path even if the user has their account pointing to a pictures folder outside of their profile (even another drive) by using:

Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)


which will return the current user's pictures folder where ever it may be.

So you would do:
Dim file As String = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "check.txt")
In Vista it is called Pictures, so the default path would be correct like that, but SpecialFolder.MyPictures is much better to use of course and works with other OS versions. There is also a My shortcut for this:
My.Computer.FileSystem.SpecialDirectories.MyPictures
 

Latest posts

Back
Top