65 848
Assignments Done
99,1%
Successfully Done
In October 2018

Answer to Question #60394 in C# for Lekorius Wallace

Question #60394
Write a program that asks the user to enter the name of a file. The program should display the number of characters in the file.
Expert's answer
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace FInfo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

/// <summary>Exit Program</summary>
private void btn_Exit_Click(object sender, EventArgs e)
{
Application.Exit();
}

/// <summary>Open file</summary>
private void btn_Open_Click(object sender, EventArgs e)
{
//Open file or return if 'Cancel' pressed
if (openFileDialogMain.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) return;

//Print file name
txt_File.Text = "File: " + openFileDialogMain.FileName;

//Counting and print the number of characters
FileInfo Inf = new FileInfo(openFileDialogMain.FileName);
txt_Number.Text = "Number of characters: " + Inf.Length.ToString();
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions