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
Fadugba Jeremiah
NA
49
18.1k
Saving Console variables to a file
Aug 23 2015 6:17 AM
Hello i want to retrieve user inputed variable from this method: they are all string and has been declared globally.
public void DetailsMovie()
{
Console.WriteLine("\n \v Enter the movie title");
MovieTitle = Console.ReadLine();
Console.WriteLine("\n Enter the year it was released");
MovieYear = Console.ReadLine();
Console.WriteLine("\n Enter the name of the movie's publisher");
MoviePublisher = Console.ReadLine();
Console.WriteLine("\n What is the length of the movie (in hours)");
MovieLength = Console.ReadLine();
}
and to be used in this place
public void SaveData()
{
Console.Write("Enter filename");
string Filename = Console.ReadLine();
if (File.Exists(Filename))
{
StreamWriter file = new StreamWriter(Filename, true);
file.WriteLine("", MovieTitle);
file.WriteLine("",MovieYear);
file.WriteLine("",MoviePublisher);
file.WriteLine("",MovieLength);
}
else
{
StreamWriter file = new StreamWriter(Filename + ".txt");
file.Write(String.Format("",MovieTitle));
file.Write(String.Format("",MovieYear));
file.Write(String.Format("",MoviePublisher));
file.Write(String.Format("",MovieLength));
file.Close();
Console.Write(" saved successful");
}
}
please how do i go about? The whole point is to save it into a text file
Reply
Answers (
1
)
Adding data to existing text file without overwriting
How to check the givem email address exists or not using ASP