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,038

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


 

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

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

Code (VB.NET)
01.Public Class Form1
02. 
03.    Private Sub Btn_SendFtp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_SendFtp.Click
04.        Try
05.            'Create Request
06.            Dim Request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://ftp.myweb.com/public_html/test.txt"), System.Net.FtpWebRequest)
07. 
08.            'Upload Properties
09.            Request.Credentials = New System.Net.NetworkCredential("user", "password")
10.            Request.Method = System.Net.WebRequestMethods.Ftp.UploadFile
11. 
12.            'Read File
13.            Dim File() As Byte = System.IO.File.ReadAllBytes("c:\myfile.text")
14. 
15.            'Upload
16.            Dim Strz As System.IO.Stream = Request.GetRequestStream()
17.            Strz.Write(File, 0, File.Length)
18. 
19.            Strz.Close()
20.            Strz.Dispose()
21. 
22.            MessageBox.Show("Upload Done", "Messsage")
23. 
24.        Catch ex As Exception
25.            MessageBox.Show(ex.Message, "Messsage")
26.        End Try
27. 
28.    End Sub
29. 
30.    Private Sub Btn_LoadFtp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_LoadFtp.Click
31.        Try
32.            My.Computer.Network.DownloadFile("http://www.myweb.com/test.txt", "c:\myfile_download.text")
33.            'Process.Start("c:\myfile_download.text")'สั่งเปิดโปรแกรม
34. 
35.            MessageBox.Show("Download Done", "Messsage")
36. 
37.        Catch ex As Exception
38.            MessageBox.Show(ex.Message, "Messsage")
39.        End Try
40.    End Sub
41. 
42.    Private Sub Btn_DelFtp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_DelFtp.Click
43.        Try
44.            'Create Request
45.            Dim Request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://ftp.myweb.com/public_html/test.txt"), System.Net.FtpWebRequest)
46. 
47.            'Upload Properties
48.            Request.Credentials = New System.Net.NetworkCredential("user", "password")
49.            Request.Method = System.Net.WebRequestMethods.Ftp.DeleteFile
50.            Request.GetResponse()
51. 
52.            MessageBox.Show("Delete Done", "Messsage")
53. 
54.        Catch ex As Exception
55.            MessageBox.Show(ex.Message, "Messsage")
56.        End Try
57.    End Sub
58.End Class


   
Hate it
Don't like it
It's ok
Like it
Love it
Total Votes: 129Overall Rating: 4.9 / 5
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
   





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