TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
harish reddy
NA
162
33.8k
Debug error with text files
Apr 10 2018 9:14 PM
Hi.I am trying to write the below program. but error is coming . Also when i debug i am getting the error message like "could not copy....." as shown in the snapshot attached. This error comes frequently for any other programs also. why is it so?
//Write simple program that counts how many times a substring(C#) occurs in a text file.
//This is our "Intro to Programming in C#" book.In it you will learn the basics of C# programming.You will find out how nice C# is.
StreamWriter writing = new StreamWriter(@"C:\Users\harish\Desktop\C Sharp\Practice\TextFiles\Occurences\Occurences.txt");
int count = 0;
if (File.Exists(@"C:\Users\harish\Desktop\C Sharp\Practice\TextFiles\Occurences\Occurences.txt"))
{
writing.Write("This is our Intro to Programming in C# book.In it you will learn the basics of C# programming.You will find out how nice C# is");
writing.Close();
StreamReader reading = new StreamReader(@"C:\Users\harish\Desktop\C Sharp\Practice\TextFiles\Occurences\Occurences.txt");
Console.WriteLine(reading.ReadLine());
string array = reading.ReadLine().Substring(0, 50);
for (int i = 0; i < array.Length; i++)
{
if (array[i] == 'C' && array[i + 1] == '#')
{
count++;
}
} Console.WriteLine(count);
reading.Close();
}
Attachment:
Capture.zip
Reply
Answers (
1
)
USING UI.grid.info
File Streams and Streamreaders