打开并阅读ASP txt文件 [英] Open and read txt file in ASP
问题描述
我想打开一个txt文件,并从中读取这里的code:
I want to open a txt file and read from it here's the code:
StreamReader reader = File.OpenText("TrackData/vehicle_points.txt");
TrckData code>在我的web应用程序的文件夹。
但我得到这个错误:
TrckData
is a folder in my web application.
but i get this error :
找不到路径的一部分C:\\ Program Files文件(x86)的\\ Common Files文件\\ Microsoft共享\\ DevServer \\ 10.0 \\ TrackData \\ vehicle_points.txt。
Could not find a part of the path 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\TrackData\vehicle_points.txt'.
我的项目是不是即使在C驱动器,我不知道它在哪里获取URL。
My project is not even in C Driver, I don't know where it gets that url.
推荐答案
ASP.Net应用程序都存储在不同的文件夹,在这里你给了一个相对可以根据asp.net的可执行文件路径有所不同。
ASP.Net applications are stored in a different folder, and here you have given a relative which may vary according to asp.net executable path.
请使用
string path = Server.MapPath("TrackData/vehicle_points.txt");
StreamReader reader = File.OpenText(path);
这肯定会工作..
这篇关于打开并阅读ASP txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!