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
Anilananda Chakrabortty
NA
425
78.4k
Text file writing in c#
May 28 2018 5:14 AM
I want to write a text file in c#... but it is giving error
Access to the path 'C:\Program Files(x86)\Anil\demoSettings.txt' is denied.
string
executableLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string
FileName = Path.Combine(executableLocation,
"demoSettings.txt"
);
var permissionSet =
new
PermissionSet(PermissionState.None);
var writePermission =
new
FileIOPermission(FileIOPermissionAccess.Write, FileName);
permissionSet.AddPermission(writePermission);
if
(permissionSet.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet))
{
using
(FileStream fstream =
new
FileStream(FileName, FileMode.Create))
using
(TextWriter sw =
new
StreamWriter(fstream))
{
sw.WriteLine(
"Name,"
+
"Anil"
);
sw.WriteLine(
"Code,"
+
"C#"
);
}
}
how to fix this ??? can anyone help me out???
Reply
Answers (
6
)
System Null Reference Exception
FarPoint.Web.Spread.ComboBoxCellType data limitation