Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi to all, This is lakshmana rao.i have an error in code
using System.IO;
    FileStream fs;
    StreamWriter sw;
    StreamReader sr;

C#
fs = new FileStream("http://localhost/jtm_site/Documents/About Me.txt", FileMode.Open, FileAccess.Read);
        sr = new StreamReader(fs);
        if (sr.Peek() > 0)
        {
            Label3.Text = sr.ReadToEnd();
        }
        fs.Flush();
        fs.Close();




The Error is "URI formats are not supported."
If i write like this
fs = new FileStream("C:\\Users\\LUCKY\\Documents\\Visual Studio 2008\\WebSites\\WebSite7\\" + s + ".txt", FileMode.Open, FileAccess.Read);
it will work for me, but i want it from localhost address. can any one suggest me.
Posted

You could try using a virtual path and call MapPath with it

C#
fs = new FileStream(MapPath("~/Documents/About Me.txt"), FileMode.Open, FileAccess.Read);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900