⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ftp.cs

📁 这个源代码是我在没有参考任何现成的代码的情况下一个字母一个字母敲进去的.目前实现了创建文件,读写文件的操作,暂时不支持子目录、长文件名、文件删除、重命名等操作。
💻 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 + -