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
Parham Torabi
NA
4
1.5k
Android Write and Read Text File in C#
Dec 7 2020 6:27 AM
I want to write a code in C# that reads a text file in Android and if it doesn't exist, create it. I want my application to read the same file everytime I run my App and create that file the first time I open my app.I wrote this code but it doesn't work.It only creates a directory if it doesn't exist but it doesn't create my text file.Thank you for your answer in advance.
string rootPath = Android.App.Application.Context.GetExternalFilesDir(
null
).ToString();
var filePathDir = Path.Combine(rootPath,
"PhoenixWallet/"
);
if
(!File.Exists(filePathDir)) {
Directory.CreateDirectory(filePathDir);
}
bitcoinPrivateKeysFile = filePathDir +
"bitcoinwallets.phoenixbtcwallet"
;
string bitcoinprivateKeyItem;
if
(File.Exists(bitcoinPrivateKeysFile) !=
null
) {
StreamReader sr = File.OpenText(bitcoinPrivateKeysFile);
while
(!sr.EndOfStream) {
bitcoinprivateKeyItem = sr.ReadLine();
bitcoinprivKeys.Add(bitcoinprivateKeyItem);
}
Console.WriteLine(
"File Exists"
);
sr.Close();
}
else
{
Key bitcoinKey =
new
Key();
BitcoinSecret bitcoinsecret =
new
BitcoinSecret(bitcoinKey, network);
StreamWriter sw;
sw = File.CreateText(bitcoinPrivateKeysFile);
sw.WriteLine(bitcoinsecret.PrivateKey);
Console.WriteLine(
"File Does not Exist"
);
sw.Close();
}
Reply
Answers (
1
)
how can i program that have socket for clients and server?
When adding PK column in group by multiple column duplicate data linq