【发布时间】:2013-03-20 11:07:46
【问题描述】:
我想从网络上的 c# 应用程序访问和编辑文本文件,并通过 ip 地址访问。访问文件不需要凭据,因此我需要一些示例代码或指南,了解如何开始完成此任务。我要编辑的文件在 Android 平板电脑上,并且我通过 ip 地址访问的 android 应用程序(SD 卡)的存储,因为我的机器和 Android 设备在同一个网络上。 谢谢
try
{
StreamReader sr = new StreamReader("192.168.1.2/NewFolder/TickerText.txt");
//Read the first line of text
line = sr.ReadLine();
//Continue to read until you reach end of file
while (line != null)
{
//write the lie to console window
textBox1.Text=line;
//Read the next line
line = sr.ReadLine();
}
//close the file
sr.Close();
Console.ReadLine();
}
catch(Exception ae)
{
textBox1.Text = ae.Message;
}
【问题讨论】:
-
你写过代码来访问本地文件吗?您在访问网络文件时遇到特定问题吗?你需要告诉我们你需要知道什么。
-
这并没有显示出任何类型的研究工作。 -1
-
可以在两台机器之间建立SMB连接吗?您是否能够创建应用程序来编辑本地文件?如果 2x 是:使用相同的技术远程编辑文件。
-
我可以编辑驱动器上的本地文件。我想通过 ftp 编辑文件,通过 ip 地址访问文件夹,因为它在网络上。
标签: c# .net winforms text-files