/// <summary> /// 在指定虚拟路径创建一个文件并创建一个写入流。 /// </summary> /// <typeparam name="T">返回值类型。</typeparam> /// <param name="virtualPathProvider">虚拟路径提供者。</param> /// <param name="virtualPath">虚拟路径。</param> /// <param name="func">对写入流的操作。</param> /// <returns>新文件的写入流。</returns> public static T CreateTextFunc <T>(this IVirtualPathProvider virtualPathProvider, string virtualPath, Func <StreamWriter, T> func) { virtualPathProvider.NotNull("virtualPathProvider"); virtualPath.NotEmptyOrWhiteSpace("virtualPath"); func.NotNull("func"); var result = default(T); virtualPathProvider.CreateText(virtualPath, stream => result = func(stream)); return(result); }
public void ResetAppDomain() { try { const string path = "~/bin/ResetAppDomain.txt"; using (StreamWriter sw = _virtualPathProvider.CreateText(path)) { sw.WriteLine("此为网站重启文件.勿动"); sw.Flush(); } } finally { } }