当前位置: 首页>>代码示例>>C#>>正文


C# FtpClient类代码示例

本文整理汇总了C#中FtpClient的典型用法代码示例。如果您正苦于以下问题:C# FtpClient类的具体用法?C# FtpClient怎么用?C# FtpClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FtpClient类属于命名空间,在下文中一共展示了FtpClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetWorkingDirectory

 public static void SetWorkingDirectory() {
     using (FtpClient conn = new FtpClient()) {
         conn.Host = "localhost";
         conn.Credentials = new NetworkCredential("ftptest", "ftptest");
         conn.SetWorkingDirectory("/full/or/relative/path");
     }
 }
开发者ID:fanpan26,项目名称:Macrosage.Wx,代码行数:7,代码来源:SetWorkingDirectory.cs

示例2: CreateDirectory

 public static void CreateDirectory() {
     using (FtpClient conn = new FtpClient()) {
         conn.Host = "localhost";
         conn.Credentials = new NetworkCredential("ftptest", "ftptest");
         conn.CreateDirectory("/test/path/that/should/be/created", true);
     }
 }
开发者ID:fanpan26,项目名称:Macrosage.Wx,代码行数:7,代码来源:CreateDirectory.cs

示例3: DeleteFile

 public static void DeleteFile() {
     using (FtpClient conn = new FtpClient()) {
         conn.Host = "localhost";
         conn.Credentials = new NetworkCredential("ftptest", "ftptest");
         conn.DeleteFile("/full/or/relative/path/to/file");
     }
 }
开发者ID:fanpan26,项目名称:Macrosage.Wx,代码行数:7,代码来源:DeleteFile.cs

示例4: Main

        static void Main(string[] args)
        {
            //args = new[] {@"c:\Users\Pz\Documents\dev\praettest.cfg"};
            args = new[] {@"c:\Users\Pz\Documents\dev\sync.cfg"};

            var configuration = ParseArgs(args);

            if (configuration == null)
            {
                PrintUsage();
            }
            else
            {
                var trackedFilesPath = args[0];

                try
                {
                    var ftp = new FtpClient(trackedFilesPath, configuration);
                    ftp.Synchronize();
                }
                catch (Exception e)
                {
                    if (!FtpClient.Handle(e)) throw;
                }
            }

            Console.WriteLine("");
            Console.WriteLine("Press any key to quit...");
            Console.ReadKey();
        }
开发者ID:martin-cech,项目名称:ftpsync,代码行数:30,代码来源:Program.cs

示例5: Main

        private static void Main(string[] args)
        {
            string hostAddress;
            string username;
            string password;

            Console.WriteLine("Reading login data...");

            /*
             * Read the login data for the server from a text-file called "Login",
             * with the following structure:
             *
             * Server address
             * Username
             * Password
             *
             */
            var loginData = File.ReadAllLines("Login");

            hostAddress = loginData[0];
            username = loginData[1];
            password = loginData[2];

            Console.WriteLine("Starting integration test...");
            Console.WriteLine();

            client = new FtpClient(new NetworkCredential(username, password));

            CreateDirectoryTest(new Uri(new Uri(hostAddress), "/TestDirectory1"));
            DeleteDirectoryTest(new Uri(new Uri(hostAddress), "/TestDirectory1"));

            Console.WriteLine();
            Console.WriteLine("Integration test finished.");
            Console.ReadLine();
        }
开发者ID:eric-seekas,项目名称:FlagFtp,代码行数:35,代码来源:Tests.cs

示例6: UploadFile

        public static void UploadFile(string ftpHost, string username, string password, string filepathToUpload, string fileToWrite)
        {
            FtpClient chipbox = new FtpClient();
            chipbox.Host = ftpHost;
            chipbox.Credentials = new NetworkCredential(username, password);

            Stream chipboxDosya = chipbox.OpenWrite(fileToWrite);
            FileStream dosya = new FileStream(filepathToUpload, FileMode.Open);

            try
            {
                int bufferSize = 8192;
                int readCount;
                byte[] buffer = new byte[bufferSize];

                readCount = dosya.Read(buffer, 0, bufferSize);
                while (readCount > 0)
                {
                    chipboxDosya.Write(buffer, 0, readCount);
                    readCount = dosya.Read(buffer, 0, bufferSize);
                }

            }
            finally
            {
                dosya.Close();
                chipboxDosya.Close();
            }
        }
开发者ID:hktaskin,项目名称:ChipboxHD,代码行数:29,代码来源:FTPTools.cs

示例7: Connect

 public static void Connect() {
     using (FtpClient conn = new FtpClient()) {
         conn.Host = "localhost";
         conn.Credentials = new NetworkCredential("ftptest", "ftptest");
         conn.Connect();
     }
 }
开发者ID:fanpan26,项目名称:Macrosage.Wx,代码行数:7,代码来源:Connect.cs

示例8: GetWorkingDirectory

 public static void GetWorkingDirectory() {
     using (FtpClient conn = new FtpClient()) {
         conn.Host = "localhost";
         conn.Credentials = new NetworkCredential("ftptest", "ftptest");
         Console.WriteLine("The working directory is: {0}",
             conn.GetWorkingDirectory());
     }
 }
开发者ID:fanpan26,项目名称:Macrosage.Wx,代码行数:8,代码来源:GetWorkingDirectory.cs

示例9: GetFileSize

 public static void GetFileSize() {
     using (FtpClient conn = new FtpClient()) {
         conn.Host = "localhost";
         conn.Credentials = new NetworkCredential("ftptest", "ftptest");
         Console.WriteLine("The file size is: {0}",
             conn.GetFileSize("/full/or/relative/path/to/file"));
     }
 }
开发者ID:Kylia669,项目名称:DiplomWork,代码行数:8,代码来源:GetFileSize.cs

示例10: DataRefresh

        void DataRefresh()
        {
            try
            {

            if (TxtData.DataBase.SoapStaus)
            {
                FtpClient ftp = new FtpClient(TxtData.XMLConfigure.IpAddress);
                ftp.DownLoadLog();

               if (   !PublicFunc.ReadCs8CLog(out date,out Txt))
               {
                   return;
               }

                if (date!=null &&Txt!=null)
                {

                    DataView dv = new DataView();
                    dv.Table = new System.Data.DataTable("Sequen");
                    dv.Table.Columns.Add();
                    dv.Table.Columns.Add();
                    dv.Table.Rows.Clear();
                   TxtData.CS8CConfigure.ViewPackaging = CB_ViewPackaging.Checked;
                    for (int i = Txt.Length - 1; i >= 0; i--)
                    {
                        if (Txt[i] != null && Txt[i].IndexOf("COM-PC:") < 0)
                        {
                            if (TxtData.CS8CConfigure.ViewPackaging)
                            {
                                if (Txt[i].IndexOf("USR:")>=0)
                                {
                                    dv.Table.Rows.Add((object[])new string[] { date[i], Txt[i] });
                                }
                            }
                            else
                            {
                                dv.Table.Rows.Add((object[])new string[] { date[i], Txt[i] });
                            }

                        }

                    }

                    GC_Alarm.DataSource = dv;
                    gv.Columns[0].Caption = "日期";
                    gv.Columns[1].Caption = "报警信息";

                }

            }

            }
            catch
            {

            }
        }
开发者ID:shumaojie,项目名称:Packaging,代码行数:58,代码来源:Frm_Cs8cAlarm.cs

示例11: ValidateCertificate

 public static void ValidateCertificate() {
     using (FtpClient conn = new FtpClient()) {
         conn.Host = "localhost";
         conn.Credentials = new NetworkCredential("ftptest", "ftptest");
         conn.EncryptionMode = FtpEncryptionMode.Explicit;
         conn.ValidateCertificate += new FtpSslValidation(OnValidateCertificate);
         conn.Connect();
     }
 }
开发者ID:fanpan26,项目名称:Macrosage.Wx,代码行数:9,代码来源:ValidateCertificate.cs

示例12: SetHashAlgorithm

        public static void SetHashAlgorithm() {
            using (FtpClient cl = new FtpClient()) {
                cl.Credentials = new NetworkCredential("user", "pass");
                cl.Host = "some.ftpserver.on.the.internet.com";

                if (cl.HashAlgorithms.HasFlag(FtpHashAlgorithm.MD5))
                    cl.SetHashAlgorithm(FtpHashAlgorithm.MD5);
            }
        }
开发者ID:fanpan26,项目名称:Macrosage.Wx,代码行数:9,代码来源:SetHashAlgorithm.cs

示例13: TestIssue3

 public void TestIssue3()
 {
     var ftpClient = new FtpClient("anonymous",
                                   string.Empty,
                                   "ftp://ftp.mozilla.org");
     var ftpListItems = ftpClient.GetListing("/");
     Assert.IsNotNull(ftpListItems);
     Assert.IsTrue(ftpListItems.Any());
 }
开发者ID:dittodhole,项目名称:dotnet-silverlight-ftp,代码行数:9,代码来源:FtpClientTest.cs

示例14: GetHashAlgorithm

        public static void GetHashAlgorithm() {
            using (FtpClient cl = new FtpClient()) {
                cl.Credentials = new NetworkCredential("user", "pass");
                cl.Host = "some.ftpserver.on.the.internet.com";

                Console.WriteLine("The server is using the following algorithm for computing hashes: {0}", 
                    cl.GetHashAlgorithm());   
            }
        }
开发者ID:fanpan26,项目名称:Macrosage.Wx,代码行数:9,代码来源:GetHashAlgorithm.cs

示例15: WindowsServerTest

 public void WindowsServerTest()
 {
     var ftpTestHost = GetTestHost("ftp", "win");
     using (var ftpClient = new FtpClient(ftpTestHost.Uri, ftpTestHost.Credential))
     {
         var i = ftpClient.ServerType;
         var s = ftpClient.StatEntries("/").ToArray();
     }
 }
开发者ID:modulexcite,项目名称:FTP,代码行数:9,代码来源:FtpClientTest.Windows.cs


注:本文中的FtpClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。