1,105,295 Community Members

URI Formats not supported

Member Avatar
muhammad.ibraheem_1
Newbie Poster
5 posts since Jul 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
public partial class _Default : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)

        Textbox.Text = "Enter your Name here";

    }
    protected void Button_Click(object sender, EventArgs e)
    {
        string Filename = "http://localhost:55688/TextFile.txt";
        if (!File.Exists(Filename))
        {
            StreamWriter txtFile = File.CreateText(Filename);
            txtFile.Close();
            txtFile = File.AppendText(Filename);
            txtFile.WriteLine(Textbox.Text);
            txtFile.Close();
        }
        else
            File.AppendAllText(Filename, Textbox.Text);

        NewName.Text = "Text is saved";
        }
    }

getting error "URI formats are not supported"

Member Avatar
pritaeas
mod_pritaeas
11,302 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,833 [?]
Skill Endorsements: 155 [?]
Moderator
Featured
Sponsor
 
0
 

File doesn't accept URL's. It needs to be an absolute or relative filepath.

Question Answered as of 3 Months Ago by pritaeas
Member Avatar
muhammad.ibraheem_1
Newbie Poster
5 posts since Jul 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i have changed it to

    string Filename = "~/textFile.txt";

and now it is saying
'Could not find a part of the path 'C:\Program Files (x86)\IIS Express\~\textFile.txt'

Member Avatar
pritaeas
mod_pritaeas
11,302 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,833 [?]
Skill Endorsements: 155 [?]
Moderator
Featured
Sponsor
 
0
 

The ~ is not automatically expanded. You can use MapPath()

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: