///将图像保存到图像文件夹
string strFileName = Path.GetFileName(uploadImage.PostedFile.FileName);
string strPath = "~/Files/";
uploadImage.SaveAs(Server.MapPath(strPath + strFileName));
/////ReadSavedFile/////
StreamReader srFileReader = new StreamReader(strPath + strFileName);
/// strPath ....显示错误我可以提供整个路径但我需要在解决方案Explorel中提供我的文件夹的路径
答案 0 :(得分:0)
string dir = System.IO.Path.GetDirectoryName( 。System.Reflection.Assembly.GetExecutingAssembly()位置);
string file = dir + @"\TestDir\TestFile.txt";
string fullDirectory = directory.FullName; string fullFile = file.FullName;
StreamReader sr = new StreamReader(@fullDirectory + fullFile);
答案 1 :(得分:0)
您可以使用:
string strPath = "../../Files/";
StreamReader srFileReader = new StreamReader(strPath + strFileName);
或复制Debug / Release文件夹中的Files文件夹并使用:
string strPath = "Files/";
StreamReader srFileReader = new StreamReader(strPath + strFileName);
答案 2 :(得分:-1)
尝试在路径
周围使用文字运算符(@)string strPath = @"〜/ Files /&#34 ;;