本文整理汇总了C#中FtpClient.ChangeDir方法的典型用法代码示例。如果您正苦于以下问题:C# FtpClient.ChangeDir方法的具体用法?C# FtpClient.ChangeDir怎么用?C# FtpClient.ChangeDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FtpClient
的用法示例。
在下文中一共展示了FtpClient.ChangeDir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
public override ProcessResult Process()
{
ProcessResult res = new ProcessResult();
res.ErrorCode = 0;
Bitmap bmp = null;
Graphics graph = null;
FtpClient ftpClient = null;
try
{
bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
graph = Graphics.FromImage(bmp);
graph.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
FileName = string.Format("zrzut_{0}-{1}-{2}_{3}.jpg", DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString(), DateTime.Now.Day.ToString(), DateTime.Now.Ticks.ToString());
bmp.Save(FileName, ImageFormat.Jpeg);
ftpClient = new FtpClient(FTPSettings.ServerAddress, FTPSettings.User, FTPSettings.Password);
ftpClient.ChangeDir(FTPSettings.Directory);
ftpClient.Upload(FileName);
System.IO.File.Delete(FileName);
}
catch (Exception exc)
{
res.ErrorCode = 5;
res.ErrorDetails = exc.ToString();
}
finally
{
if (ftpClient != null)
ftpClient.Close();
if (graph != null)
graph.Dispose();
if (bmp != null)
bmp.Dispose();
}
return res;
}
示例2: CopyFileToFTP
private ProcessResult CopyFileToFTP()
{
ProcessResult pr = new ProcessResult();
FtpClient ftpClient = null;
pr.ErrorCode = 3;
try
{
if (!File.Exists(RequestedObjectPath))
{
pr.ErrorDetails = "Plik " + RequestedObjectPath + " nie istnieje";
return pr;
}
ftpClient = new FtpClient(FTPSettings.ServerAddress, FTPSettings.User, FTPSettings.Password);
ftpClient.ChangeDir(FTPSettings.Directory);
ftpClient.Upload(RequestedObjectPath);
pr.ErrorCode = 0;
}
catch (Exception exc)
{
pr.ErrorDetails = exc.ToString();
}
finally
{
try
{
if (ftpClient != null)
{
ftpClient.Close();
}
}
catch { }
}
return pr;
}
示例3: CopyFileFromFTP
private ProcessResult CopyFileFromFTP()
{
ProcessResult pr = new ProcessResult();
FtpClient ftpClient = null;
pr.ErrorCode = 3;
try
{
ftpClient = new FtpClient(FTPSettings.ServerAddress, FTPSettings.User, FTPSettings.Password);
ftpClient.ChangeDir(FTPSettings.Directory);
ftpClient.Download(RequestedObjectPath, DestinationObjectPath);
pr.ErrorCode = 0;
}
catch (Exception exc)
{
pr.ErrorDetails = exc.ToString();
}
finally
{
try
{
if (ftpClient != null)
{
ftpClient.Close();
}
}
catch { }
}
return pr;
}