Writing a text file to the file system
From: cwbp (cwbp_at_discussions.microsoft.com)
Date: 03/22/05
- Next message: Ignus Fast: "Re: Error instantiating RSACryptoServiceProvider"
- Previous message: Mark Teague: "Forms auth / Location element"
- Next in thread: Joe Kaplan \(MVP - ADSI\): "Re: Writing a text file to the file system"
- Reply: Joe Kaplan \(MVP - ADSI\): "Re: Writing a text file to the file system"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 21 Mar 2005 15:11:09 -0800
Using Visual Studio C#
When I ran the following code:
System.IO;
private void Button1_Click(object sender, System.EventArgs e)
{
//FileStream fs = File.Create(Server.MapPath("test.txt"));
FileStream fs = File.Create("C:\\MYSAVEDFILES\\test.txt");
StreamWriter sw = new StreamWriter(fs);
sw.Write(TextBox1.Text);
sw.Close();
fs.Close();
}
I initially got an error message that "access was denied." The message
suggested that I give ASP.NET user access rights/permissions to the folder.
I then [manually] gave the logged in user write permission to the folder.
Then, when I ran the above code, the text file was created.
Is there another way [i.e., programatically using C#] to allow my code to
write a text file to the file system without giving access rights to a user?
Can the permissions be given to the app [the code] instead of to a user?
Any suggestions would be appreciated.
Thanks.
bebop
- Next message: Ignus Fast: "Re: Error instantiating RSACryptoServiceProvider"
- Previous message: Mark Teague: "Forms auth / Location element"
- Next in thread: Joe Kaplan \(MVP - ADSI\): "Re: Writing a text file to the file system"
- Reply: Joe Kaplan \(MVP - ADSI\): "Re: Writing a text file to the file system"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]