Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > บทความจากสมาชิก > VB.NET Upload / Download / Delete ผ่าน FTP



 
Clound SSD Virtual Server

VB.NET Upload / Download / Delete ผ่าน FTP

การทำ Window App (VB.NET) สั่งให้ Upload / Download / Delete ไฟล์ที่อยู่ Server Host เป็นบทความที่ลองเขียนเป็นครั้งแรกหากผิดพลาดประการใดต้องขออภัยมา ณ ที่นี้ด้วยครับ

Code (VB.NET)
Public Class Form1

    Private Sub Btn_SendFtp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_SendFtp.Click
        Try
            'Create Request
            Dim Request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://ftp.myweb.com/public_html/test.txt"), System.Net.FtpWebRequest)

            'Upload Properties
            Request.Credentials = New System.Net.NetworkCredential("user", "password")
            Request.Method = System.Net.WebRequestMethods.Ftp.UploadFile

            'Read File
            Dim File() As Byte = System.IO.File.ReadAllBytes("c:\myfile.text")

            'Upload
            Dim Strz As System.IO.Stream = Request.GetRequestStream()
            Strz.Write(File, 0, File.Length)

            Strz.Close()
            Strz.Dispose()

            MessageBox.Show("Upload Done", "Messsage")

        Catch ex As Exception
            MessageBox.Show(ex.Message, "Messsage")
        End Try

    End Sub

    Private Sub Btn_LoadFtp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_LoadFtp.Click
        Try
            My.Computer.Network.DownloadFile("http://www.myweb.com/test.txt", "c:\myfile_download.text")
            'Process.Start("c:\myfile_download.text")'สั่งเปิดโปรแกรม

            MessageBox.Show("Download Done", "Messsage")

        Catch ex As Exception
            MessageBox.Show(ex.Message, "Messsage")
        End Try
    End Sub

    Private Sub Btn_DelFtp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_DelFtp.Click
        Try
            'Create Request
            Dim Request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://ftp.myweb.com/public_html/test.txt"), System.Net.FtpWebRequest)

            'Upload Properties
            Request.Credentials = New System.Net.NetworkCredential("user", "password")
            Request.Method = System.Net.WebRequestMethods.Ftp.DeleteFile
            Request.GetResponse()

            MessageBox.Show("Delete Done", "Messsage")

        Catch ex As Exception
            MessageBox.Show(ex.Message, "Messsage")
        End Try
    End Sub
End Class







   
Share
Bookmark.   

  By : babyprogrammer
  Article : บทความเป็นการเขียนโดยสมาชิก หากมีปัญหาเรื่องลิขสิทธิ์ กรุณาแจ้งให้ทาง webmaster ทราบด้วยครับ
  Score Rating :
  Create Date : 2012-04-25
  Download : Download  VB.NET Upload / Download / Delete ผ่าน FTP (0.0194 MB)
Sponsored Links
ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่