Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How can i pushed a generated Excel report to the ftp mail server?
Posted
Comments
Sergey Alexandrovich Kryukov 8-Mar-12 19:51pm    
And how could it be a problem?
--SA

1 solution

For programmatic use of FTP server, use the class System.Net.FtpWebRequest, http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx[^].

—SA
 
Share this answer
 
Comments
Alan Tuscano 11-Mar-12 4:01am    
Hi SA,

Thank you.. but my new problem is, when the uppoad is done, I checked the Excel file, and the workbook was empty?
Sergey Alexandrovich Kryukov 11-Mar-12 4:04am    
You are welcome.

It's really hard to say where could you screw up the document, without any your code sample or other information.
--SA
Alan Tuscano 11-Mar-12 20:43pm    
Hi SA,

Here the Code,

Imports System.IO
Imports System
Imports System.Data
Imports System.Net.FtpWebRequest
Imports System.Configuration
Imports System.Configuration.ConfigurationManager

Private Function CreateFTPFile(ByVal FileName As String, _
ByVal ServerName As String, ByVal UserID As String, _
ByVal Password As String, ByVal FTPFolderName As String, _
ByVal UploadedFileDirectory As String, ByVal FTPFileName As String) As String

Try
FTPFileName = FTPFileName & FileName '& ".xls"
Dim FPTWriter As New StreamWriter(FTPFileName, True)
Try
FPTWriter.WriteLine("open " & ServerName)
FPTWriter.WriteLine(UserID)
FPTWriter.WriteLine(Password)
FPTWriter.WriteLine("cd " & FTPFolderName)
FPTWriter.WriteLine("put """ & UploadedFileDirectory & FileName & """")
FPTWriter.WriteLine("close")
Return FTPFileName
Catch ex As Exception
msg = "Function:CreateFTPFile - " & ex.Message
Throw New Exception(msg)
Finally
FPTWriter.Close()
End Try
Catch ex As Exception
msg = "Function:CreatetxtFile - " & ex.Message
Throw New Exception(msg)
End Try
End Function

Yes, I did compare the uploaded and the original document.


Thanks in advance SA.
Sergey Alexandrovich Kryukov 12-Mar-12 11:50am    
And does it cause any problems?
--SA
Sergey Alexandrovich Kryukov 12-Mar-12 11:51am    
What is FPTWriter?
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900