PDA

View Full Version : سوال: آپلود کردن فایل



AliRezaBeytari
یک شنبه 29 بهمن 1391, 16:36 عصر
سلام...چطوری میشه برنامه ای رو در VB.NET نوشت که وقتی اجرا بشه ؛ خودش به طور خودکار یه فایل رو ، مثلا E:\Test.exe رو در اینترنت آپلود کنه یا به یه ایمیل بفرسته؟؟؟؟

saeedgholami
یک شنبه 29 بهمن 1391, 16:55 عصر
سلام

Imports System.IO Module module1 Sub Main() Const MyUsername As String = "MyUsername" Const MyPassword As String = "MyPassword" Const MyFileName As String = "PurchaseInvoice.mht" Const MyPathToFile As String = "C:\PurchaseInvoice.mht" ' You may download this file from http://www.postalmethods.com/files/templates/PurchaseInvoice.mht ' Set account permissions for this file: Const MyPermissions As com.postalmethods.api.Permissions = com.postalmethods.api.Permissions.Account ' Set Overwrite mode: Const FileUploadOverwrite As Boolean = False Dim objPM As New com.postalmethods.api.PostalWS() Dim lngResult As Long ' Read file to upload and convert to binary. In this case, the file is C:\PurchaseInvoice.mht ' You may download this file from http://www.postalmethods.com/files/templates/PurchaseInvoice.mht Dim MyFile As Byte() = IO.File.ReadAllBytes(MyPathToFile) ' Invoke the UploadFile method lngResult = objPM.UploadFile( _ MyUsername, _ MyPassword, _ MyFileName, _ MyFile, _ MyPermissions, _ FileUploadOverwrite) ' ' Check response status ' If lngResult = -3000 Then ' ' If the result code = -3000, the file was uploaded successfully and it is ready for use. ' Console.WriteLine("File uploaded successfully!") Else ' ' A negative value means an error occurred. ' See the PostalMethods Status Codes: http://www.postalmethods.com/statuscodes#webservice. ' Console.WriteLine("An error occurred:" & lngResult) End If ' In debug mode, the following lines prevent your console application from closing automatically upon termination Console.WriteLine("Hit ENTER to terminate application") Console.ReadLine() End Sub End Module

zahedi121
یک شنبه 29 بهمن 1391, 17:00 عصر
سلام...چطوری میشه برنامه ای رو در VB.NET نوشت که وقتی اجرا بشه ؛ خودش به طور خودکار یه فایل رو ، مثلا E:\Test.exe رو در اینترنت آپلود کنه یا به یه ایمیل بفرسته؟؟؟؟

با سلام
یک سری به اینجا بزن با یکم تغییر ( تعریف فایلت به عنوان پیش فرض ) حل میشه :
http://barnamenevis.org/showthread.php?264995-ارسال-ایمیل-Attach-File

AliRezaBeytari
دوشنبه 30 بهمن 1391, 13:55 عصر
سلام

Imports System.IO Module module1 Sub Main() Const MyUsername As String = "MyUsername" Const MyPassword As String = "MyPassword" Const MyFileName As String = "PurchaseInvoice.mht" Const MyPathToFile As String = "C:\PurchaseInvoice.mht" ' You may download this file from http://www.postalmethods.com/files/templates/PurchaseInvoice.mht ' Set account permissions for this file: Const MyPermissions As com.postalmethods.api.Permissions = com.postalmethods.api.Permissions.Account ' Set Overwrite mode: Const FileUploadOverwrite As Boolean = False Dim objPM As New com.postalmethods.api.PostalWS() Dim lngResult As Long ' Read file to upload and convert to binary. In this case, the file is C:\PurchaseInvoice.mht ' You may download this file from http://www.postalmethods.com/files/templates/PurchaseInvoice.mht Dim MyFile As Byte() = IO.File.ReadAllBytes(MyPathToFile) ' Invoke the UploadFile method lngResult = objPM.UploadFile( _ MyUsername, _ MyPassword, _ MyFileName, _ MyFile, _ MyPermissions, _ FileUploadOverwrite) ' ' Check response status ' If lngResult = -3000 Then ' ' If the result code = -3000, the file was uploaded successfully and it is ready for use. ' Console.WriteLine("File uploaded successfully!") Else ' ' A negative value means an error occurred. ' See the PostalMethods Status Codes: http://www.postalmethods.com/statuscodes#webservice. ' Console.WriteLine("An error occurred:" & lngResult) End If ' In debug mode, the following lines prevent your console application from closing automatically upon termination Console.WriteLine("Hit ENTER to terminate application") Console.ReadLine() End Sub End Module



میشه بیشتر توضیح بدید یا یه سورس بزارید؟؟