📄 ftp.cs
字号:
using System;
namespace FTP
{
/// <summary>
/// Contains some general functions used by the FTP system.
/// </summary>
public class FTP
{
public FTP()
{
}
public static string getParentDirectory(){
// this function works for /main/db/test/ as well as /main/db/test.aspx
System.Web.HttpContext context = System.Web.HttpContext.Current;
string path = context.Session["Path"].ToString();
if(path == "./")
return("../"); // trivial, no string manipulation required
else if(path == "/")
return("/"); // can't go higher than root
else
{
// remove trailing "/" at end of path
if(path.LastIndexOf("/") == path.Length-1){
path = path.Remove(path.LastIndexOf("/"), (path.Length - path.LastIndexOf("/")));
}
try
{
// remove the characters after the last occurence of / in the string. => parent directory
path = path.Remove(path.LastIndexOf("/"), (path.Length - path.LastIndexOf("/")));
return(path + "/");
}
catch(ArgumentOutOfRangeException ex)
{
return("/"); // default to root;
}
}
}
public static void ReportError(string problem, string tech, string suggestion)
{
// outputs error, in english, and in tech, and with any suggestions.
System.Web.HttpContext context = System.Web.HttpContext.Current;
string output = "<font color=red><BIG>Problem:</BIG> " + problem + "</font><hr>";
output += "Suggestion: " + suggestion + "<hr>";
output += "<small>Technical details: " + tech + "</small><hr>";
context.Response.Write(output);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -