C#_fileinfo file attribute class and DirectoryInfo folder attribute class

Source: Internet
Author: User
Tags parent directory
Using System;
Using System.Collections;
Using System.Collections.Generic;
Using System.IO;
Using System.Linq;
Using System.Text;

Using Litjson;
            Namespace Cshapetest {class Start {static void Main (string[] args) {////file attribute class

            FileInfo FileInfo = new FileInfo ("Skill.json");
            Gets whether the file exists//bool bexists = fileinfo.exists;

            Console.WriteLine (bexists);
            Gets the filename//string name = Fileinfo.name;

            Console.WriteLine (name);
            Get file Superior path//string directory = Fileinfo.directoryname;

            Console.WriteLine (directory);
            Gets whether the file is read-only//bool isreadonly = fileinfo.isreadonly;

            Console.WriteLine (isreadonly); Directory attribute class DirectoryInfo DirectoryInfo = new DirectoryInfo (@ "C:\Users\chen\Documents\Visual Studio 2013\projects

            \cshapetest\cshapetest\bin\debug ");
     To get whether a directory exists       bool bexists = directoryinfo.exists;

            Console.WriteLine (bexists);
            Gets the current directory string name = Directoryinfo.name;

            Console.WriteLine (name);
            Get parent Directory String parent = DirectoryInfo.Parent.ToString ();

            Console.WriteLine (parent);
            Gets the root string root = DirectoryInfo.Root.ToString ();

            Console.WriteLine (root);
        Console.ReadLine (); }
    }
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.