代码拉取完成,页面将自动刷新
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace demo_win_httpsocket
{
partial class MainForm
{
/// <summary>
/// 查找对应Key的Value
/// </summary>
/// <param name="result"></param>
/// <param name="code"></param>
/// <param name="regex"></param>
/// <returns></returns>
string SearchKey(string result, string code, string regex)
{
if (result.IndexOf(code) != -1)
{
Regex reg = new Regex(regex);
Match m = reg.Match(result);
while (m.Success)
{
return m.Groups[1].Value;
}
}
//没有找到
throw new Exception("SearchKey not find \"" + code + "\"");
}
string SubString(
string objValue,
string indexStr = "",
string lastStr = "",
string iDefault = "",
bool throwE = false)
{
try
{
int index = objValue.IndexOf(indexStr);
if (lastStr != "" && index > -1)
{
objValue = objValue.Remove(0, index);
index = objValue.IndexOf(indexStr);
}
int last = objValue.IndexOf(lastStr);
last = last == 0 ? objValue.Length : last;
if (index > -1 && last > -1)
{
objValue = objValue.Substring(index + indexStr.Length, last - (index + indexStr.Length));
return objValue;
}
else
{
return iDefault;
}
}
catch (Exception error)
{
if (throwE) throw error;
return iDefault;
}
}
string GetDIName(string skey)
{
if (USER_DI.ContainsKey(skey))
return USER_DI[skey];
return skey;
}
String generateDeviceId()
{
StringBuilder sb = new StringBuilder();
sb.Append("e");
int count = 15;//15个随机数字
Random ran = new Random();
for (int i = 0; i < count; i++)
{
int num = (int)(ran.Next(10));
sb.Append(num);
}
return sb.ToString();
}
string CreateWeiXinFilesFolder(string folder = "files")
{
//存储到本地
var filesFolder = Path.Combine(Application.StartupPath, folder);
if (!Directory.Exists(filesFolder))
Directory.CreateDirectory(filesFolder);
return filesFolder;
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。