I have a form: when the user fills a form, the application takes this information and creates a data file (.csv) and put it (data file) on the server in a directory (name of this directory is [information]) where the web site is located.
C# Copy
using (System.IO.StreamWriter SW = new System.IO.StreamWriter(Server.MapPath("save/information/Data_" + strDate + ".csv" )))
{
SW.WriteLine(s.FirstName + ";" + s.LastName + ";" + s.Address1 + ";" );
SW.Close();
}
After, I changed the path for save the file, in a different server than the Web server
Code Copy
StreamWriter SW = new StreamWriter(@"\\111.222.1.00\c$\Inetpub\wwwroot\site_toto\ save\information\Data_" + strDate + ".csv");
It must disable the firewall on server so that it works. I can't it.
So instead of filing the file with system Windows, I'd like to put with FTP protocole on another place, but I do not know how I can do.
I have a class!(by J.P. Trosclair)
How can I integrate it? Is that correct if I do like that ? : C# Copy
using (FTP ftplib = new FTP(MapPath ("Data_" + strDate + ".csv" )));
try
{
ftplib.Connect("ftp.toto.com" ,
"tata" ,
"pata" );
ftplib.ChangeDir("information/" );
}
catch (Exception ex)
{
Console.WriteLine(s.FirstName + ";" + s.LastName + ";" + s.Address1 + ";" );
}
try
{
int perc = 0 ;
ftplib.OpenDownload("Data_" + strDate + ".csv" , true );
while (ftplib.DoDownload() > 0 )
{
perc = (int )((ftplib.BytesTotal * 100 ) / ftplib.FileSize);
Console.Write("\rDownloading: {0}/{1} {2}%" ,
ftplib.BytesTotal, ftplib.FileSize, perc);
Console.Out.Flush();
}
Console.WriteLine("" );
}
catch (Exception ex)
{
Console.WriteLine("" );
Console.WriteLine(ex.Message);
}
What do you think of my integration code that you see above? is that this can work or I'm completely wrong
the beginning of the code should I add [using ftplib]
[(using System;)after :]
jingeRank #2,527 · 554 reputationPosted Oct 15, 2009, 6:11 PM EDT