File Comparison in C# compare 2 files from doc and txt RRS feed

  • Question

  • I am having problems creating this program named File Comparison that compares two files. A file comparison application that displays the sizes of the two files as well as the ratio of their sizes to each other. To discover a file's size, you can create a System.IO.FileInfo object using statements such as the following, where File_Name is a string that contains the name of the file, and size has been declared as an integer:

    FileInfo fileInfo= new FileInfo( File_Name);

    Size = fileInfo. Length;

    I am having trouble figuring out how to do this. Please help!

    Sunday, June 3, 2018 11:14 PM

All replies

  • It looks right, the way you are doing it. If you use these statements it should give you back the size of the file:

    FileInfo fi = new FileInfo(filePath);
    long size = fi.Length;

    This should work. If it is "giving you trouble", please give us a bit more detail about what exactly the trouble is.

    Monday, June 4, 2018 6:10 AM