如何从通过lan连接的系统读取和写入文件 [英] how to read and write to the file from the system connected through lan

查看:77
本文介绍了如何从通过lan连接的系统读取和写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  public   partial   class 关于:System.Web.UI.Page 
{
public string newcontnt = ;
public string oldcontent = ;

受保护 void Page_Load( object sender,EventArgs e)
{
newcontnt = Request.QueryString [ NEWCON];
oldcontent = Request.QueryString [ oldcon];

writetofile(newcontnt,oldcontent);
}

private void writetofile( string newcontnt, string oldcontent)
{

string text = File.ReadAllText( @ \\192.168.7.103\testdata。 TXT);
string textn = newcontnt;
string texto = oldcontent;
text = text.Replace(texto,textn);
File.WriteAllText( @ \\192.168.7.101\testdata.txt,文字);
Response.Redirect( http://localhost/test61.html);

}
}

在此代码中显示网络名称未找到错误

解决方案

理想情况下,路径应该是......



\\IP\\ \\SharedFolderPath\FileName

public partial class About : System.Web.UI.Page
{
    public string newcontnt = "";
    public string oldcontent = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        newcontnt = Request.QueryString["newcon"];
        oldcontent = Request.QueryString["oldcon"];

        writetofile(newcontnt, oldcontent);
    }

    private void writetofile(string newcontnt, string oldcontent)
    {

        string text = File.ReadAllText(@"\\192.168.7.103\testdata.txt");
        string textn = newcontnt;
        string texto = oldcontent;
        text = text.Replace(texto, textn);
        File.WriteAllText(@"\\192.168.7.101\testdata.txt", text);
        Response.Redirect("http://localhost/test61.html");

    }
}

in this code its showing network name not found error

解决方案

Ideally the path should be like...

\\IP\SharedFolderPath\FileName


这篇关于如何从通过lan连接的系统读取和写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆