Hello im a new member to this forum so if this is in the wrong place im very sorry.

any way i have been developing a piece of software that reads from a .txt file soo far i have got it working but only on my pc eg "c:\documents and settings\........" so on and so forth i was wondering if anyone knew how to make the application be able to read form the file on any computer i tried

String fileLocation = ConsoleApplication1.StartupPath + "textFile.txt";

but this dident seem to work (just to let you know i am quite new to programming) the code i have at the moment that works is

    StreamReader objReader = new StreamReader("C:\\Documents and Settings\\Owner\\Desktop\\Ascii reader\\Enter Your Ascii Picture here.txt");
            string sLine = "";
            ArrayList arrText = new ArrayList();

            while (sLine != null)
                sLine = objReader.ReadLine();
                if (sLine != null)

            foreach (string sOutput in arrText)
            Console.WriteLine("Thank You For Useing DaN BrOwN'S Ascii Reader");

i was wondering if there was any way of adapting the above code to make it so it could find that file after an install on any computer if that makes sence :confused:

well thanks very much kind regards zixizx.

Check Environment class. There's Environment.SpecialFolder enumeration and Environment.GetFolderPath method.

For example

string myFullPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\" + @"Enter Your Ascii Picture here.txt";
StreamReader objReader = new StreamReader(myFullPath);

would work with Win XP as well as Win 7 and with all users of the PC.


hi thankyou for the reply and for the help but i am allmost completely new to this so i have no idea where to put the code you suggested :confused:

tyvm for your help i got it working :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.