求解。局域网内操作共享文件
有两台服务器 webA和webB , webB上面有一个共享文件夹test。我在webA上面映射一个虚拟目录testA,目标位置是webB上面的共享文件夹test。想通过webA的虚拟目录testA去 读写webB上的test文件夹。
代码:
private string MakeGameHtml(int gameid)
{
string rlt = "";
string txt = iRadioHtml.ShowGame(this.Page, gameid, 320);
rlt += BuildHtmlFile("test/static/game/" + gameid, "game_top.html", txt);
txt = iRadioHtml.ShowGame2(this.Page, gameid, 320);
rlt += BuildHtmlFile("test/static/game/" + gameid, "game_middle.html", txt);
txt = iRadioHtml.GetListGame(320, gameid.ToString());
rlt += BuildHtmlFile("test/static/game/" + gameid, "game_bottom.html", txt);
return rlt;
}
//写
private string BuildHtmlFile(string path, string filename, string txt)
{
string fpath = System.Web.HttpContext.Current.Server.MapPath(path);
if (!Directory.Exists(fpath)) Directory.CreateDirectory(fpath);
string fname = fpath + "\\" + filename;
if (File.Exists(fname)) File.Delete(fname);
if (iFile.SaveTxtFile(fname, BindHtml(txt))) return "";
return "创建或修改文件" + filename + "失败!";
}
//删除
public void GetDetele(int id)
{
string fpath2 = System.Web.HttpContext.Current.Server.MapPath("test/static/game/");
string fpath = System.Web.HttpContext.Current.Server.MapPath("test/static/game/" + id);
//获取fpath2路径的文件夹下面的子文件
string[] filelist = Directory.GetFileSystemEntries(fpath2);
foreach (string file in filelist)
{
if (!file.Equals(fpath))
{
//获取file路径的文件夹下面的子文件并删除
string[] filelist2 = Directory.GetFileSystemEntries(file);
foreach (string itme in filelist2)
{
if (File.Exists(itme)) File.Delete(itme);
}
//删除file路径的文件夹
bool ss2 = File.Exists(file);
if (Directory.Exists(file)) Directory.Delete(file);
}
}
}
错误信息。
Server Error in '/' Application.
--------------------------------------------------------------------------------
登录失败: 未知的用户名或错误密码。
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.IOException: 登录失败: 未知的用户名或错误密码。
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace: