C# Read file on the remote PC
来源:互联网 发布:博睿软件测试 编辑:程序博客网 时间:2024/06/01 11:26
//Function1;
private string SendUrl(string Host)
{
string StrReturn = "";
WebResponse result = null;
try
{
WebRequest req = WebRequest.Create(Host);
result = req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("GB2312");
StreamReader sr = new StreamReader(ReceiveStream, encode);
Char[] read = new Char[256];
int count = sr.Read(read, 0, 256);
while (count > 0)
{
String str = new String(read, 0, count);
StrReturn += str;
count = sr.Read(read, 0, 256);
}
}
catch (Exception e)
{
StrReturn += e.ToString();
StrReturn += "找不到请求 URI,或者它的格式不正确";
}
finally
{
if (result != null)
{
result.Close();
}
}
return StrReturn.Trim();
}
string url="http://www.*******";
string strData = SendUrl(url);
string[] strRecs = strData.Trim().Replace("\r\n", "#").Replace("\r", "#").Replace("\n", "#").Replace("\t", "#").Split('#');
if (strRecs.Length > 0)
{
for (int i = 0; i < strRecs.Length; i++)
{
string[] strs = strRecs[i].Replace(" ",",").Split(',');
if (strs.Length == 7)
{
Response.Write(strs[1]+","+strs[2]);
}
}
}
//Function2;
public static void WriteFile(string Path, string Content)
{
try
{
string path = HttpContext.Current.Server.MapPath(Path);
if (System.IO.File.Exists(path) == false)
{
using (StreamWriter sw = new StreamWriter(path, false, System.Text.Encoding.GetEncoding("GB2312")))
{
sw.WriteLine(Content);
sw.Flush();
sw.Close();
}
}
}
catch
{
}
}
private string SendUrl(string Host)
{
string StrReturn = "";
WebResponse result = null;
try
{
WebRequest req = WebRequest.Create(Host);
result = req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("GB2312");
StreamReader sr = new StreamReader(ReceiveStream, encode);
Char[] read = new Char[256];
int count = sr.Read(read, 0, 256);
while (count > 0)
{
String str = new String(read, 0, count);
StrReturn += str;
count = sr.Read(read, 0, 256);
}
}
catch (Exception e)
{
StrReturn += e.ToString();
StrReturn += "找不到请求 URI,或者它的格式不正确";
}
finally
{
if (result != null)
{
result.Close();
}
}
return StrReturn.Trim();
}
string url="http://www.*******";
string strData = SendUrl(url);
string[] strRecs = strData.Trim().Replace("\r\n", "#").Replace("\r", "#").Replace("\n", "#").Replace("\t", "#").Split('#');
if (strRecs.Length > 0)
{
for (int i = 0; i < strRecs.Length; i++)
{
string[] strs = strRecs[i].Replace(" ",",").Split(',');
if (strs.Length == 7)
{
Response.Write(strs[1]+","+strs[2]);
}
}
}
//Function2;
public static void WriteFile(string Path, string Content)
{
try
{
string path = HttpContext.Current.Server.MapPath(Path);
if (System.IO.File.Exists(path) == false)
{
using (StreamWriter sw = new StreamWriter(path, false, System.Text.Encoding.GetEncoding("GB2312")))
{
sw.WriteLine(Content);
sw.Flush();
sw.Close();
}
}
}
catch
{
}
}
- C# Read file on the remote PC
- Write on the Android Read-only file system
- C# read XML file
- sysHotel On Line Remote File Disclosure Vulnerability
- How to create and kill processes on remote PC
- The Configuration File – “remote” Section
- cannot read file on virtual machine
- abap:read file list on server
- Read only file system on Android
- C# copy file to remote shared folder
- Read the Last line in a file
- python-read the file contains Chinese
- Install the Windows Service on PC
- Details of GRUB on the PC
- C# Read and Modify XML File
- C# read excel and CSV file
- Using the Metasploit PHP Remote File Include Module
- The Configuration File – “remote” Section – Git Config
- 深入浅出之正则表达式(一)
- Two PC SQL Server Synchronise
- lambda过程作为返回值的例子-分析,及一个作用域的例子
- 线程里面访问类的私有成员变量flag,不报错,诧异,求解!
- 深入浅出之正则表达式(二)
- C# Read file on the remote PC
- Just in Time Compiler (JIT) in Hotspot
- 如何区分直连串口线和交叉串口线?
- oracle Sql 语句创建JOB
- Concurrency vs Parallelism, Concurrent Programming vs Parallel Programming
- 关于firmware的思考
- cocoa内存autorelease pool原理
- SurfaceView
- 传搜狐300万年薪挖角完美