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
Rohan Ramani
NA
786
145.1k
How to open and read .txt file in UWP?
Aug 31 2020 8:00 AM
Hi All,
How to open and read .txt file in UWP?
I am getting "Access denied" error by using below code.
using
(OpenFileDialog openFileDialog =
new
OpenFileDialog())
{
openFileDialog.InitialDirectory =
"c:\\"
;
openFileDialog.Filter =
"txt files (*.txt)|*.txt|All files (*.*)|*.*"
;
openFileDialog.FilterIndex = 2;
openFileDialog.RestoreDirectory =
true
;
if
(openFileDialog.ShowDialog() == DialogResult.OK)
{
//Get the path of specified file
filePath = openFileDialog.FileName;
//Read the contents of the file into a stream
var fileStream = openFileDialog.OpenFile();
using
(StreamReader reader =
new
StreamReader(fileStream))
{
fileContent = reader.ReadToEnd();
}
}
}
MessageBox.Show(fileContent,
"File Content at path: "
+ filePath, MessageBoxButtons.OK);
Please provide the solution.
Reply
Answers (
1
)
how to draw over an image in xamarin forms
Is it possible to create UI control other then main thread