我在这里询问是否有任何C#函数允许我通过某个FtpWebRequest
或Stream
发现上次上传文件的目录,因此我可以将其存储在MySQL中数据库以后?
感谢您的帮助。
JoãoBorrego
编辑:
此功能:
public static string uploadftp(string filename, string ftpserver, string user, string pass)
{
System.Net.FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpserver);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(user, pass);
Stream ftpStream = request.GetRequestStream();
FileStream file = File.OpenRead(filename);
int length = Convert.ToInt32(file.Length);
byte[] buffer = new byte[length];
int bytesRead = 0;
do
{
bytesRead = file.Read(buffer, 0, length);
ftpStream.Write(buffer, 0, bytesRead);
}
while (bytesRead != 0);
file.Close();
//supposed get directory code
ftpStream.Close();
//return directory
}
答案 0 :(得分:0)
您可以将文件观察程序用作FTP文件夹的根文件夹。当使用文件名上传文件时会触发它,你可以将它存储在mysql中。