creating a data file - a little direction help please

Discussion in 'ASP.NET / ASP.NET Core' started by allenfr, Jan 18, 2011.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. 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");
     
  2. Joseph Jun

    Joseph Jun DiscountASP.NET Staff

    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 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.
     
  3. Thanks !

    That worked just fine. Thank you !
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page