当前位置: 首页>>代码示例>>C#>>正文


C# FileInfo.CreateSubdirectory方法代码示例

本文整理汇总了C#中System.IO.FileInfo.CreateSubdirectory方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.CreateSubdirectory方法的具体用法?C# FileInfo.CreateSubdirectory怎么用?C# FileInfo.CreateSubdirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.FileInfo的用法示例。


在下文中一共展示了FileInfo.CreateSubdirectory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompileClientScript

        public static void CompileClientScript(Assembly a)
        {
            var moduleFile = new FileInfo(a.Location);
            var module = moduleFile.FullName;

            var dir = new FileInfo(module).Directory;

            var web = dir.CreateSubdirectory("web");

            Environment.CurrentDirectory = dir.FullName;


            jsc.Program.Main(new[] { module, "-js" });
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:14,代码来源:WebTools.cs

示例2: Main

		static void Main(string[] args)
		{
			Console.WriteLine("This application will help you port an actionscript application to c#.");

			// fixme: this should be a parameter instead
			var project = @"C:\work\code.google\dodging-basenji\examples\actionscript\doomedonline\Doomedonline\Doomedonline.csproj";

			XNamespace ns = "http://schemas.microsoft.com/developer/msbuild/2003";

			var doc = XDocument.Load(
				project
			);

			const string prefix = @"web\";
			const string suffix = ".as";

			var SourceFiles =
				from ItemGroup in doc.Root.Elements(ns + "ItemGroup")
				from Compile in ItemGroup.Elements(ns + "Compile")
				let Include = Compile.Attribute("Include").Value
				where Include.EndsWith(".cs")
				select new { ItemGroup, Include };

			var DefaultSourceFileGroup = SourceFiles.First();

			foreach (var h in
			  from ItemGroup in doc.Root.Elements(ns + "ItemGroup")
			  from File in ItemGroup.Elements(ns + "None")
			  let Include = File.Attribute("Include").Value
			  where Include.EndsWith(suffix)
			  where Include.StartsWith(prefix)
			  let FullName = Include.Substring(prefix.Length, Include.Length - prefix.Length - suffix.Length)
			  select new { FullName }
				)
			{
				var Segments = h.FullName.Split('\\');

				var dir = new FileInfo(project).Directory;
				var Namespace = "";

				foreach (var s in Segments.Take(Segments.Length - 1))
				{
					if (Namespace != "")
						Namespace += ".";

					Namespace += s;

					dir = dir.CreateSubdirectory(s);
				}

				var TypeName = Segments.Last();

				var Writer = new StringWriter();

				Writer.WriteLine(@"
using ScriptCoreLib;
using ScriptCoreLib.ActionScript;
using ScriptCoreLib.ActionScript.Extensions;
using ScriptCoreLib.ActionScript.flash.display;
using ScriptCoreLib.ActionScript.flash.text;
using ScriptCoreLib.ActionScript.flash.filters;
");

				if (Namespace != "")
				{
					Writer.WriteLine(@"
namespace " + Namespace + @"
{
");
				}

				Writer.WriteLine(@"
	[Script(IsNative = true)]
	public class " + TypeName + @"
	{
		// This class is a stub. You should implement it as it is currently implemented by actionscript.
	}
");

				if (Namespace != "")
				{
					Writer.WriteLine(@"
}
");
				}

				var TargetFile = Path.Combine(dir.FullName, TypeName + ".cs");

				if (!File.Exists(TargetFile))
					File.WriteAllText(TargetFile, Writer.ToString());

				var TargetSourceFile = SourceFiles.FirstOrDefault(k => k.Include == h.FullName + ".cs");
				if (TargetSourceFile != null)
				{
				}
				else
				{
					DefaultSourceFileGroup.ItemGroup.Add(
						new XElement(ns + "Compile", new XAttribute("Include", h.FullName + ".cs"))
					);
//.........这里部分代码省略.........
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:101,代码来源:Program.cs

示例3: logging

        private void logging(ErrorType eType, String message)
        {
            lock (loggingConsoleLocker)
                if (errorLevelIsMinRequire(writeToConsole, eType))
                    Console.Error.WriteLine(message);

            lock (loggingFileLocker)
                if (errorLevelIsMinRequire(writeToFile, eType) && logPath != "")
                {
                    try
                    {
                        var tmp = logPath;
                        DirectoryInfo dir = new FileInfo(tmp).Directory;
                        if (!dir.Exists)
                            dir.CreateSubdirectory(new FileInfo(tmp).Directory.FullName);

                        System.IO.File.AppendAllText(tmp, message);
                    }
                    catch (Exception e)
                    {
                        Console.Error.WriteLine(parseException(e));
                    }
                }
        }
开发者ID:bawaaaaah,项目名称:PonyLogManager,代码行数:24,代码来源:LogManager.cs

示例4: Build

        private static bool Build(string projectFilePath, IDictionary<string, string> buildProperties,
            LoggerVerbosity verbosity, string logPath = null)
        {
            var workspace = new FileInfo(projectFilePath).Directory;
            if (workspace == null)
                throw new DirectoryNotFoundException(
                    "Somehow the project file is not in a directory. Report this to Icedream!");

            // Mono compatibility
            Environment.SetEnvironmentVariable("MONO_IOMAP", "all");

            // Make sure we restore nuget packages automatically and without permissions interfering with /tmp/nuget/ (edge case)
            var newTempDir = workspace.CreateSubdirectory(".tmp");
            Environment.SetEnvironmentVariable("EnableNuGetPackageRestore", "true");
            Environment.SetEnvironmentVariable("TEMP", newTempDir.FullName);
            Environment.SetEnvironmentVariable("TMP", newTempDir.FullName);

            try
            {
                var pc = new ProjectCollection();
                pc.RegisterLogger(new ConsoleLogger(verbosity));

                var loggers = new List<ILogger>();
                if (logPath != null)
                    loggers.Add(new FileLogger
                    {
                        Parameters = string.Format("LogFile={0}", logPath),
                        Verbosity = LoggerVerbosity.Detailed,
                        ShowSummary = true,
                        SkipProjectStartedText = true
                    });
                loggers.Add(new ConsoleLogger(verbosity) {ShowSummary = false});

                // Import/Update Mozilla certs for NuGet to not fail out on non-Windows machines
                if (!Environment.OSVersion.IsWin32())
                {
                    try
                    {
                        var automaticYesResponder = new Action<string, StreamWriter>((s, writer) =>
                        {
                            if (s == null || !s.Contains("X.509 Certificate"))
                                return;
                            writer.WriteLine("yes");
                        });

                        // TODO: Make sure this does not fail out by checking if mozroots is installed
                        Console.WriteLine("Updating SSL certificates for NuGet...");
                        RunProcessThrowOnException("mozroots", "--import --sync --quiet");
                        RunProcessThrowOnException("certmgr", "-ssl https://go.microsoft.com",
                            lineProcessor: automaticYesResponder);
                        RunProcessThrowOnException("certmgr", "-ssl https://nugetgallery.blob.core.windows.net",
                            lineProcessor: automaticYesResponder);
                        RunProcessThrowOnException("certmgr", "-ssl https://nuget.org",
                            lineProcessor: automaticYesResponder);
                    }
                    catch (Exception error)
                    {
                        Console.Error.WriteLine("ERROR: {0}", error.Message);
                        throw;
                    }
                }

                {
                    // The NuGet.exe that is shipped with CitizenMP.Server has a few bugs...
                    var nugetExePath = Path.Combine(workspace.FullName, ".nuget", "NuGet.exe");
                    Console.WriteLine("Updating NuGet...");
                    File.Delete(nugetExePath);
                    using (var wc = new WebClient())
                    {
                        wc.DownloadFile("https://nuget.org/NuGet.exe", nugetExePath);
                    }
                }

                // Use a different build route if running on the Mono interpreter
                if (!Environment.OSVersion.IsWin32())
                {
                    Console.WriteLine("Building server binaries...");
#pragma warning disable 618
                    // Build doesn't work with the new API on Mono, use the deprecated api
                    var engine = Engine.GlobalEngine;

                    // loggers
                    foreach (var logger in loggers)
                        engine.RegisterLogger(logger);

                    // Apply build properties
                    var buildPropertiesConverted = new BuildPropertyGroup();
                    engine.GlobalProperties = buildPropertiesConverted;
                    foreach (var property in buildProperties)
                        buildPropertiesConverted.SetProperty(property.Key, property.Value);

                    // Load project
                    var result = engine.BuildProjectFile(projectFilePath, new string[0], null, null,
                        BuildSettings.None,
                        null);
#pragma warning restore 618
                    return result;
                }

                // Windows build can make use of the new API which is more efficient
//.........这里部分代码省略.........
开发者ID:ap0110,项目名称:citizenmp-server-updater,代码行数:101,代码来源:Program.cs


注:本文中的System.IO.FileInfo.CreateSubdirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。