พัฒนา Window CE ต้องทำการสร้างโฟลเดอร์ไดเรกทอรี่ไว้เก็บรูปภาพ
แต่ยังสร้างโฟลเดอร์บนไดร์ของเซิฟเวอร์ไม่ได้
Code (VB.NET)
'Create folder current year
System.IO.Directory.CreateDirectory("Nand\\" & year & "")
'Create folder current jun in folder year
System.IO.Directory.CreateDirectory("Nand\\" & year & "\\" & jun & "")
'Create folder current item no. in folder jun
System.IO.Directory.CreateDirectory("Nand\\" & year & "\\" & jun & "\\" & item & "")
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
Dim strPath As String = "\\Program Files\\MyApp"
'*** Create Folder Data 1***//
Dim Dir1 As New DirectoryInfo(strPath + "\Data1")
If Not Dir1.Exists Then
Dir1.Create()
End If
Dir1 = Nothing
'*** Create Folder Data 2 ***//
Dim Dir2 As New DirectoryInfo(strPath + "\Data1")
If Not Dir2.Exists Then
Dir2.Create()
End If
Dir2 = Nothing