473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

default directory when reading TXT files...

Hello all!

I've created an ASP.NET project using Visual Studio 2003 and C#. The project is quite basic in that it simply needs to read in the contents of a text file (.txt).

I have the StreamReader in place, but my problem arises when trying to local the file. I added my text file to my project in VS. I thought just putting the filename would locate the file thinking the default directory is the project directory: StreamReader("myFile.txt").

However, the program does not find the file. Instead, when I display the 'Path.GetFullPath(".")' I get: "C:\WINNT\system32".

I need the file to be read on my development machine (which is "localhost") and without program changes or hard-coding directory information, I also need it to read the file on my server when I copy the project out to the web.

Any suggestions would be greatly appreciated. I'm confident this issue is simple, but not from where I sit right now.

Thank you!

Mark
Jul 21 '05 #1
1 1187
On Fri, 24 Oct 2003 09:21:33 -0700, "Mark" <an*******@discussions.microsoft.com> wrote:

¤ Hello all!
¤
¤ I've created an ASP.NET project using Visual Studio 2003 and C#. The project is quite basic in that it simply needs to read in the contents of a text file (.txt).
¤
¤ I have the StreamReader in place, but my problem arises when trying to local the file. I added my text file to my project in VS. I thought just putting the filename would locate the file thinking the default directory is the project directory: StreamReader("myFile.txt").
¤
¤ However, the program does not find the file. Instead, when I display the 'Path.GetFullPath(".")' I get: "C:\WINNT\system32".
¤
¤ I need the file to be read on my development machine (which is "localhost") and without program changes or hard-coding directory information, I also need it to read the file on my server when I copy the project out to the web.
¤
¤ Any suggestions would be greatly appreciated. I'm confident this issue is simple, but not from where I sit right now.
¤

Try Request.PhysicalApplicationPath.
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: o'seally | last post by:
solaris/linux admins/rookie_developers that battle with this error are probably all frustrated when it happens. i bet you're also somehow frustrated by this seemingly unsolvable error :-) ...take...
0
by: John Caruthers | last post by:
HELP! This problem is driving me crazy. All other web sites that are being served out through this server are working, including sites and virtual directories that are under the Default Web...
2
by: 73blazer | last post by:
Hello, I'm writing some C++ code, and I need to be able to find the number of files in a given directory. Is it possible under AIX4.3.3 with C++ 3.6.4? I cannot seem to locate anything of this...
0
by: Nick | last post by:
I am getting the following error when creating a new CacheDependency object: Failed to start monitoring changes to '\\server\share\dir49' This error happens after 48 successful instantiations of...
3
by: Nick | last post by:
Is it possible to read a list of files from a specified directory using VB.net We have company intranet and I have created a page that displays photos from different events. I have coded a page...
1
by: Mark | last post by:
Hello all! I've created an ASP.NET project using Visual Studio 2003 and C#. The project is quite basic in that it simply needs to read in the contents of a text file (.txt). I have the...
23
by: **Developer** | last post by:
Is there an easy way to copies all files in a directory into another directory? What about coping subdirectories too? Thanks in advance for any info
4
by: Jim | last post by:
I have the following piece of code: Directory.CreateDirectory(myDir); DirectoryInfo lDir = new DirectoryInfo(myDir); lDir.Attributes = FileAttributes.Normal; When this code runs, my directory...
2
by: supra91 | last post by:
Hi, I have to read files from the parent directory and delete those files. This parent directory contains logs files. This directory also contains some sub directories and I do not want to delete...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.