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


C# System.IO.DirectoryInfo.ToString方法代码示例

本文整理汇总了C#中System.IO.DirectoryInfo.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.DirectoryInfo.ToString方法的具体用法?C# System.IO.DirectoryInfo.ToString怎么用?C# System.IO.DirectoryInfo.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.DirectoryInfo的用法示例。


在下文中一共展示了System.IO.DirectoryInfo.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: backupSSF

        public static void backupSSF()
        {
            //verifica se existe o diretório, caso não exista será criado
            string dirAnteriores = Library.appDir + "\\ssf\\anteriores\\";
            if (!System.IO.Directory.Exists(dirAnteriores))
            {
                System.IO.Directory.CreateDirectory(dirAnteriores);
            }

            //verifica se existe o diretório, caso não exista será criado
            string dirZipados = Library.appDir + "\\ssf\\zipados\\";
            if (!System.IO.Directory.Exists(dirZipados))
            {
                System.IO.Directory.CreateDirectory(dirZipados);
            }

            //backup ssf
            System.IO.DirectoryInfo dirSSF = new System.IO.DirectoryInfo(appDir + "\\ssf");

            string[] filePaths = System.IO.Directory.GetFiles(dirSSF.ToString(), "*.ssf");

            ZipFile zip =
                new ZipFile(dirZipados + DateTime.Now.Day + DateTime.Now.Month + DateTime.Now.Year +
                    DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".zip");
            zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
            zip.AddFiles(filePaths);
            zip.Save();

            //move todos os arquivos
            foreach (string file in filePaths)
                System.IO.File.Move(file, dirAnteriores + System.IO.Path.GetFileName(file));
        }
开发者ID:alphaman8,项目名称:CIP_beta1,代码行数:32,代码来源:Library.cs

示例2: option1_create_key

        //this will add new keys, then deactive the others
        private static void option1_create_key()
        {
            MySQL_Interface MySQL = new MySQL_Interface();

            string Errors = "";
            //System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
            System.Console.Write("Creating Keys..." + Environment.NewLine);
            System.Security.Cryptography.RSACryptoServiceProvider provider = new System.Security.Cryptography.RSACryptoServiceProvider(); //make keys in c#
            System.Console.Write("Keys Created." + Environment.NewLine);

            System.Console.WriteLine("Connecting to database and deactivating past keys...");
            if (MySQL.mysql_clear_old_key(my_username,my_password,my_database))
            {
                Console.WriteLine("Old Keys Deactivated");
            }
            else
            {
                Errors += "Error disabling old keys" + "|" + "Run command 'database-maintance'" + "|";
                Console.WriteLine("Error disabling old keys");
                Console.WriteLine("Manually deactivte old keys or empty table, im not a english major spelling is for computers, and awake people");
            }

            System.Console.WriteLine("Inserting new key, and activating...");
            int time = Convert.ToInt32((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds); // get unix time stamp for easy use
            string mod = BitConverter.ToString(provider.ExportParameters(false).Modulus).Replace("-", string.Empty).ToLower(); //public key parts of ssl
            string expon = BitConverter.ToString(provider.ExportParameters(false).Exponent).Replace("-", string.Empty);

            //Public key parts get put in database to be used in web end, the rest of the key is saved to the hard drive so that just a local app can decrypt

            string mysql_command = "INSERT INTO `" + my_database + "`.`" + my_db_table +  "` (`index` ,`modulus` ,`exponent`,`active`,`date_added`) VALUES (NULL , '" + mod + "', '" + expon + "',  '1',  '" + time + "')";
            if (MySQL.mysql_nonquery(my_username, my_password, my_database, mysql_command))
            {
                //Save local key pairs
                string index_of = MySQL.mysql_select_cell(my_username, my_password, my_database, "SELECT * FROM `" + my_database + "`.`" + my_db_table +  "` WHERE `modulus`='" + mod + "' AND `date_added`='" + time + "'", "index");
                System.IO.DirectoryInfo Working_dir = new System.IO.DirectoryInfo(System.Environment.CurrentDirectory);
                string working_dir = Working_dir.ToString();
                local_store_key(working_dir, index_of, provider);
            }
            else
            {
                Console.Write("Error putting key in database" + Environment.NewLine);
            }
        }
开发者ID:daberkow,项目名称:PHP_PublicKeyDemo,代码行数:44,代码来源:Main.cs

示例3: local_store_key

        //this will write the keys to the hard drive
        private static string local_store_key(string passed_data_store, string keyID, RSACryptoServiceProvider passed_provider)
        {
            System.IO.DirectoryInfo Working_dir = new System.IO.DirectoryInfo(passed_data_store);
            System.IO.DirectoryInfo Keys_Dir = new System.IO.DirectoryInfo(System.IO.Path.Combine(Working_dir.ToString(), "keys"));
            if (Working_dir.Exists)
            {
                //Directory is good for storage
                if (!Keys_Dir.Exists)
                {
                    try
                    {
                        Keys_Dir.Create();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                        return e.ToString();
                    }
                }
            }
            else
            {
                try
                {
                    Working_dir.Create();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    return e.ToString();
                }
                //No keys directory
                try
                {
                    Keys_Dir.Create();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    return e.ToString();
                }
            }
            Working_dir = null;
            //Keys Dir should work now
            System.IO.FileInfo Key_file = new System.IO.FileInfo(Keys_Dir.ToString() + System.IO.Path.DirectorySeparatorChar + keyID + ".key");
            using (System.IO.StreamWriter sw = Key_file.CreateText())
            {
                sw.Write(BitConverter.ToString(passed_provider.ExportCspBlob(true)));
                Console.WriteLine("Key Stored in 'keys'");
                //Console.WriteLine(BitConverter.ToString(passed_provider.ExportCspBlob(true)));
                //Console.WriteLine();
                //Console.WriteLine(BitConverter.ToString(passed_provider.ExportCspBlob(true)).Replace("-", string.Empty));

            }
            return "yes";
        }
开发者ID:daberkow,项目名称:PHP_PublicKeyDemo,代码行数:57,代码来源:Main.cs


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