473,503 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

default directory when reading a TXT file

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
Nov 17 '05 #1
2 1097
Look at using Server.MapPath( "/myFile.txt" );

and see what that returns.

bill

"Mark" <an*******@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
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

Nov 17 '05 #2
Bill -- that did it! Thank you!

For some reason I keep getting an error message when I try to reply to the message you posted; hence I'm trying to reply to my original.

Thanks again,

Mark
Nov 17 '05 #3

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

Similar topics

1
10265
by: SPG | last post by:
Hi, I am relatively new to TOMCAT, and am trying to deploy a web app using it. I have a domain name that I want to use to access my web app directly. By default, I deploy my WAR, and it deploys...
3
3633
by: Kali K E | last post by:
Hi, I could not understand how I can do the following things in Python. Please help me. 1. First I have to find the current directory from where the script is invoked. 2. Next I have to form a...
6
16598
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...
1
1190
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...
2
11141
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...
39
2610
by: Joe Laughlin | last post by:
If I have a character array with "/some/file/directory/file_name", are there any functions / libraries that I could use to separate the directory ("some/file/directory") from the file name...
3
3749
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...
23
2395
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
1473
by: Craig Vermeer | last post by:
Hi All, I have a program that's using the file system as a queuing mechanism, and it's consuming an inordinate amount of CPU time when the file system queue gets all that large (any more than a...
0
7204
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
7282
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
7342
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...
1
6998
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
7464
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...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5018
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
391
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.