Govind Sankar
Active member
- Joined
- May 15, 2020
- Messages
- 42
- Programming Experience
- Beginner
I have attached the c# project Excel Export. The first part of the project is reading from a text file using a stream reader and storing it in a sting file and displaying it using console.writeline. I tried doing this by watching a youtube video. But when I run the
program nothing is happening. I can see its written Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll. What is the problem. Can anyone help me. You can go through the project. Its a very small one. Thank you.
This is the class
This is the end of the class
This is the beginning of the main Program
This is the end of the main Program
program nothing is happening. I can see its written Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll. What is the problem. Can anyone help me. You can go through the project. Its a very small one. Thank you.
This is the class
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace ExcelExport
{
class TextReader
{
string filePath = @"\\\\10.10.10.101\\kpg data\\Transfer\\Govind\\Cell Block Production Improvement\\Cell Block Production Project\\Phase 1\\Project Data\\Type of Data to be saved in Database.";
string DataInsideText = "";
StreamReader reader = null;
public string readDataInsideText()
{
try
{
reader = new StreamReader(filePath);
DataInsideText = reader.ReadLine();
while(DataInsideText != null)
{
Console.WriteLine(DataInsideText);
DataInsideText = reader.ReadLine();
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
return DataInsideText;
}
}
}
This is the end of the class
This is the beginning of the main Program
C#:
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace ExcelExport
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello");
TextReader text = new TextReader();
string data = text.readDataInsideText();
Console.WriteLine(data);
}
}
}
This is the end of the main Program