IsSymLink() публичный статический Метод

public static IsSymLink ( string path ) : bool
path string
Результат bool
Пример #1
0
        static private void PruneOldLogs()
        {
            DateTime      magic_date = DateTime.Now.AddDays(-7);
            DirectoryInfo dir        = new DirectoryInfo(log_directory);

            string current_str;

            current_str = "current-" + program_identifier;

            foreach (FileInfo file in dir.GetFiles())
            {
                // Clean up old symlinks
                if (file.Name.StartsWith(current_str) && FileSystem.IsSymLink(file.FullName))
                {
                    // Work around a Mono bug in which FileInfo.Delete()
                    // doesn't delete dangling symlinks.  See
                    // http://bugzilla.ximian.com/show_bug.cgi?id=78664

                    //file.Delete ();
                    File.Delete(file.FullName);

                    continue;
                }

                int last_dash = file.Name.LastIndexOf("-");
                if (last_dash == -1)
                {
                    continue;                     // skip strange-looking files
                }
                string date = file.Name.Substring(0, last_dash);

                try {
                    DateTime log_date;
                    log_date = DateTime.ParseExact(date, "yyyy-MM-dd-HH-mm-ss", null);
                    if (log_date < magic_date)
                    {
                        file.Delete();
                    }
                } catch { }
            }
        }