PDA

View Full Version : creating a data file - a little direction help please


allenfr
01-18-2011, 01:32 PM
If someone could point me in the right direction, please:

On my page load I want to open a temp.txt file, write one short string to it, and close it.

The only thing I consistantly get is this:

Could not find a part of the path 'C:\Content\App_LocalResources\temp.txt'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Content\App_LocalResources\temp.txt'.

Source Error:


Line 29: {
Line 30: // Create a file to write to.
Line 31: StreamWriter sw = File.CreateText("/Content/App_LocalResources/temp.txt");
Line 32: {
Line 33: sw.WriteLine("Opening new file");

Joseph Jun
01-18-2011, 02:00 PM
If you're running into the problem on your web site that's hosted with us, it's because the path that's being used.

Using the physical path may help. You can find the server path on the Account Information (https://my.discountasp.net/account-info.aspx) page in your CP so you will want to use the server path and then try the following:

StreamWriter sw = File.CreateText("e:\web\user\htdocs\Content\App_LocalResources\temp .txt");

I think that should work.

allenfr
01-18-2011, 02:58 PM
That worked just fine. Thank you !