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


C# DirectoryInfo.CreateSubdirectory方法代码示例

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


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

示例1: btnupload_Click

        protected void btnupload_Click(object sender, EventArgs e)
        {
            string aud;
            aud = "Audio";

            string tempFolderAbsolutePath;
            tempFolderAbsolutePath = Server.MapPath("ShareData//");
            string subFolderRelativePath = @"Audio";//@"SubTemp1";

            DirectoryInfo tempFolder = new DirectoryInfo(tempFolderAbsolutePath);
            DirectoryInfo subFolder = tempFolder.CreateSubdirectory(subFolderRelativePath);

            string tempFileName = String.Concat(Guid.NewGuid().ToString(), @".MP3");

            string str = Path.GetExtension(FileUpload1.PostedFile.FileName);
            if ((str == ".mp3") || (str == ".wav") || (str == ".wma") || (str == ".aiff") || (str == ".au"))
            {
                FileUpload1.SaveAs(subFolder.FullName + "\\" + FileUpload1.FileName);
                SqlConnection con = new SqlConnection();
                SqlCommand cmd = new SqlCommand();
                con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=D:\\CloudTest\\Irain-M\\Irain-M\\App_Data\\Database.mdf;Integrated Security=True;User Instance=True";
                con.Open();
                cmd.Connection = con;
                cmd.CommandText = "insert into sharedetails(filename,username,date,category) values ('" + FileUpload1.FileName + "','" + Label1.Text + "','" + DateTime.Now + "','" + aud + "')";
                cmd.ExecuteNonQuery();
                con.Close();
                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                               "alert('Audio uploaded successfully!'); window.location.href = 'share.aspx';", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                                          "alert('This file format is not supported in this section!'); window.location.href = 'share.aspx';", true);
            }
        }
开发者ID:kishanchaitanya,项目名称:Cloud-Storage-Prototype,代码行数:35,代码来源:audioupload.aspx.cs

示例2: ArchiveException

        /// <summary>
        /// Archives the exception report.
        /// The name of the PDF file is modified to make it easier to identify.
        /// </summary>
        /// <param name="pdfFile">The PDF file.</param>
        /// <param name="archiveDirectory">The archive directory.</param>
        public static void ArchiveException(FileInfo pdfFile, string archiveDirectory)
        {
            // Create a new subdirectory in the archive directory
            // This is based on the date of the report being archived
            DirectoryInfo di = new DirectoryInfo(archiveDirectory);
            string archiveFileName = pdfFile.Name;
            string newSubFolder = ParseFolderName(archiveFileName);
            try
            {
                di.CreateSubdirectory(newSubFolder);
            }
            catch (Exception ex)
            {
                // The folder already exists so don't create it
            }

            // Create destination path
            // Insert _EXCEPT into file name
            // This will make it easier to identify as an exception in the archive folder
            string destFileName = archiveFileName.Insert(archiveFileName.IndexOf("."), "_EXCEPT");
            string destFullPath = archiveDirectory + "\\" + newSubFolder + "\\" + destFileName;

            // Move the file to the archive directory
            try
            {
                pdfFile.MoveTo(destFullPath);
            }
            catch (Exception ex)
            {
            }
        }
开发者ID:RonFields72,项目名称:EmailACHReportsToVendors,代码行数:37,代码来源:FileHelper.cs

示例3: CopyDirectoryTree

        public static bool CopyDirectoryTree(this DirectoryInfo source, DirectoryInfo dest)
        {
            bool wasModified = false;

            if (!Directory.Exists(dest.FullName))
                Directory.CreateDirectory(dest.FullName);

            foreach (FileInfo file in source.EnumerateFiles())
            {
                var fileDest = Path.Combine(dest.ToString(), file.Name);
                if (!File.Exists(fileDest))
                {
                    file.CopyTo(fileDest);
                    wasModified = true;
                }
            }

            foreach (DirectoryInfo subDirectory in source.GetDirectories())
            {
                var dirDest = Path.Combine(dest.ToString(), subDirectory.Name);
                DirectoryInfo newDirectory = dest.CreateSubdirectory(subDirectory.Name);
                if (CopyDirectoryTree(subDirectory, newDirectory))
                    wasModified = true;
            }

            return wasModified;
        }
开发者ID:niv,项目名称:ArmALauncher,代码行数:27,代码来源:Helpers.cs

示例4: DeepCopy

        /// <summary>
        /// Deep copy directory
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        public static void DeepCopy(DirectoryInfo source, DirectoryInfo target)
        {
            try
            {
                // Recursively call the DeepCopy Method for each Directory
                foreach (DirectoryInfo dir in source.GetDirectories())
                {
                    DirectoryInfo subDir = target.CreateSubdirectory(dir.Name);

                    // --- IMPROVED SECTION ---
                    // Set the security settings for the new directory same as the source dir
                    subDir.SetAccessControl(new DirectorySecurity(dir.FullName, AccessControlSections.All));
                    DeepCopy(dir, target.CreateSubdirectory(dir.Name));
                }

                // Go ahead and copy each file in "source" to the "target" directory
                foreach (FileInfo file in source.GetFiles())
                {
                    file.CopyTo(Path.Combine(target.FullName, file.Name), true); // allow overwrite
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
开发者ID:S-origin,项目名称:Tam.Framework,代码行数:31,代码来源:DirectoryHerlper.cs

示例5: Main

        static void Main(string[] args)
        {
            var directory = new DirectoryInfo(args[0]);
            var slides=directory.CreateSubdirectory("LaTeXCompiledSlides");
            slides.Delete(true);
            slides.Create();

            var latexDirectory = directory.CreateSubdirectory("LaTeX");
            var files = latexDirectory.GetFiles("L*.tex");
            var galleries = new List<GalleryInfo>();
            var processor = new LatexProcessor();

            foreach (var file in files)
            {
                var doc = processor.Parse(file);
                var docs = doc.Sections.Select(z => new LatexDocument { Preamble = doc.Preamble, Sections = new List<LatexSection> { z } }).ToList();
                int number = 0;
                foreach (var e in docs)
                {
                    var pdf = processor.Compile(e, latexDirectory);
                    var targetDirectory = slides.CreateSubdirectory(file.Name + "." + number);
                    processor.ConvertToPng(pdf, targetDirectory);
                    galleries.Add(new GalleryInfo { Name = e.LastSection.Name, Directory=targetDirectory });
                    number++;
                }
            }

            var matcher =
                Matchers.ByName<VideoItem, GalleryInfo>(galleries, z => z.Name, (a, b) => a.Directory.FullName == b.Directory.FullName);

            var model = EditorModelIO.ReadGlobalData(directory);
            var root = ItemTreeBuilder.Build<FolderItem, LectureItem, VideoItem>(model);
            matcher.Push(root);
            DataBinding<VideoItem>.SaveLayer<GalleryInfo>(root, directory);
        }
开发者ID:IvanSorokin,项目名称:Tuto,代码行数:35,代码来源:Program.cs

示例6: CraftitudeProfile

        // Constructor
        /// <summary>
        /// Open a profile (create if not exist) and load it.
        /// </summary>
        /// <param name="profileDirectory">The root directory of the profile</param>
        public CraftitudeProfile(DirectoryInfo profileDirectory)
        {
            Directory = profileDirectory;

            _craftitudeDirectory = Directory.CreateSubdirectory("craftitude");
            _craftitudeDirectory.CreateSubdirectory("repositories"); // repository package lists
            _craftitudeDirectory.CreateSubdirectory("packages"); // cached package setups

            _bsonFile = _craftitudeDirectory.GetFile("profile.bson");

            if (!_bsonFile.Exists)
            {
                ProfileInfo = new ProfileInfo();
            }
            else
            {
                using (FileStream bsonStream = _bsonFile.Open(FileMode.OpenOrCreate))
                {
                    using (var bsonReader = new BsonReader(bsonStream))
                    {
                        var jsonSerializer = new JsonSerializer();
                        ProfileInfo = jsonSerializer.Deserialize<ProfileInfo>(bsonReader) ?? new ProfileInfo();
                    }
                }
            }
        }
开发者ID:Craftitude-Team,项目名称:Craftitude,代码行数:31,代码来源:Profile.cs

示例7: CreateNewPackage

        private void CreateNewPackage(string name, string version)
        {
            var runtimeForPacking = TestUtils.GetClrRuntimeComponents().FirstOrDefault();
            if (runtimeForPacking == null)
            {
                throw new InvalidOperationException("Can't find a CLR runtime to pack test packages.");
            }

            var runtimeHomePath = base.GetRuntimeHomeDir((string)runtimeForPacking[0],
                                                         (string)runtimeForPacking[1],
                                                         (string)runtimeForPacking[2]);

            using (var tempdir = new DisposableDir())
            {
                var dir = new DirectoryInfo(tempdir);
                var projectDir = dir.CreateSubdirectory(name);
                var outputDir = dir.CreateSubdirectory("output");
                var projectJson = Path.Combine(projectDir.FullName, "project.json");

                File.WriteAllText(projectJson, [email protected]"{{
  ""version"": ""{version}"",
  ""frameworks"": {{ 
      ""dnx451"": {{ }}
  }}
}}");
                DnuTestUtils.ExecDnu(runtimeHomePath, "restore", projectJson);
                DnuTestUtils.ExecDnu(runtimeHomePath, "pack", projectJson + " --out " + outputDir.FullName, environment: null, workingDir: null);

                var packageName = string.Format("{0}.{1}.nupkg", name, version);
                var packageFile = Path.Combine(outputDir.FullName, "Debug", packageName);

                File.Copy(packageFile, Path.Combine(PackageSource, packageName), overwrite: true);
            }
        }
开发者ID:leloulight,项目名称:dnx,代码行数:34,代码来源:PackageManagerFunctionalTestFixture.cs

示例8: AnnotateCorpus

        protected override void AnnotateCorpus(
            Corpus corpus, System.Threading.CancellationToken token)
        {
            token.ThrowIfCancellationRequested();

            Guid taskId = Guid.NewGuid();

            DirectoryInfo dir = new DirectoryInfo(
                AppDomain.CurrentDomain.BaseDirectory);

            dir = dir.CreateSubdirectory("Tasks");
            dir = dir.CreateSubdirectory(taskId.ToString());

            string dataFile = dir.FullName + "\\Corpus.crfppdata";
            string outputFile = dir.FullName + "\\Output.crfppdata";

            try
            {
                AnnotationProgressChangedEventArgs ePrepared =
                    new AnnotationProgressChangedEventArgs(
                        1, 3, MessagePreparing);
                OnAnnotationProgressChanged(ePrepared);

                CRFPPHelper.EncodeCorpusToCRFPPData(corpus, dataFile);
                token.ThrowIfCancellationRequested();

                AnnotationProgressChangedEventArgs eAnnotating =
                    new AnnotationProgressChangedEventArgs(
                        2, 3, MessageAnnotating);
                OnAnnotationProgressChanged(eAnnotating);

                CRFPPHelper.Annotate(
                    Model.RootPath, dataFile, outputFile, 1, 0);
                token.ThrowIfCancellationRequested();

                AnnotationProgressChangedEventArgs eFinishing =
                    new AnnotationProgressChangedEventArgs(
                        3, 3, MessageFinishing);
                OnAnnotationProgressChanged(eFinishing);

                CRFPPHelper.DecodeCorpusFromCRFPPData(corpus, outputFile);
                token.ThrowIfCancellationRequested();
            }
            catch
            {
                throw;
            }
            finally
            {
                File.Delete(dataFile);
                File.Delete(outputFile);

                try
                {
                    dir.Delete();
                }
                catch { }
            }
        }
开发者ID:Ran-QUAN,项目名称:Alta,代码行数:59,代码来源:CRFPPAnnotator.cs

示例9: ModifyAppDirectory

        static void ModifyAppDirectory() {
            DirectoryInfo dir = new DirectoryInfo(".");

            dir.CreateSubdirectory("MyFolder");
            DirectoryInfo myDataFolder = dir.CreateSubdirectory(@"MyFolder\Data");
            Console.WriteLine("New folderr is {0}", myDataFolder);
            Console.WriteLine();
        }
开发者ID:Geronimobile,项目名称:DotNetExamIntro,代码行数:8,代码来源:Program.cs

示例10: createProjectFolder

 /// <summary>
 /// Create Project Folder
 /// <para>Programmer:Sarwan</para>
 /// <para>lab.uyghurdev.net</para>
 /// </summary>
 /// <param name="strRootPath"></param>
 public void createProjectFolder(string strRootPath)
 {
     DirectoryInfo di = new DirectoryInfo(strRootPath);
     if (!di.Exists)
     {
         di.Create();
     }
     di.CreateSubdirectory( Settings.PICTURE_FOLDER);//Create Picture folder in root folder
     di.CreateSubdirectory( Settings.SOUND_FOLER);//Create Sound folder in root folder.
 }
开发者ID:Sarwan,项目名称:Picture-Book-Creator,代码行数:16,代码来源:FileManager.cs

示例11: WurmPlayer

 public WurmPlayer(DirectoryInfo playerDir, string name, Platform targetPlatform)
 {
     Name = name;
     this.playerDir = playerDir;
     DumpsDir = playerDir.CreateSubdirectory("dumps");
     LogsDir = playerDir.CreateSubdirectory("logs");
     ScreenshotsDir = playerDir.CreateSubdirectory("screenshots");
     ConfigTxt = new FileInfo(Path.Combine(playerDir.FullName, "config.txt"));
     File.WriteAllText(ConfigTxt.FullName, string.Empty);
     Logs = new WurmLogs(LogsDir, targetPlatform);
 }
开发者ID:imtheman,项目名称:WurmApi,代码行数:11,代码来源:WurmPlayer.cs

示例12: Export

        public void Export(string dir)
        {
            throw new NotImplementedException();

            DirectoryInfo exportDir = new DirectoryInfo(dir);

            Dictionary<World, tempDictTwo> dict = new Dictionary<World, tempDictTwo>();

            var maps = exportDir.CreateSubdirectory("Maps");
            var graphics = exportDir.CreateSubdirectory("Graphics");
            var data = exportDir.CreateSubdirectory("Data");

            foreach (var world in this.WorldsList)
            {
                maps.CreateSubdirectory(world.Value.Name);
                graphics.CreateSubdirectory(world.Value.Name);

                tempDictTwo td = new tempDictTwo();

                foreach (var map in world.Value.MapList)
                {
                    tempStorage t = new tempStorage();
                    t.oldTexture = map.Value.Map.TextureName;
                    t.oldPath = map.Value.MapFileLocation;

                    td.dict.Add(map.Value.Map, t);

                    var pictStrings = map.Value.Map.TextureName.Split(new char[] { '\\', '.' });
                    string imageExt = pictStrings.Last();

                    map.Value.MapFileLocation = Path.Combine (world.Value.Name, map.Value.Map.Name + ".xml");
                    String newTexturePath = Path.Combine (world.Value.Name, map.Value.Map.Name + "." + imageExt);

                    File.Copy(Path.Combine (TileEngine.TextureManager.TextureRoot, map.Value.Map.TextureName), Path.Combine (graphics.FullName, newTexturePath), true);
                    map.Value.Map.TextureName = newTexturePath;

                    //map.Value.Map.Save(Path.Combine(maps.FullName, map.Value.MapFileLocation));
                }

                dict.Add(world.Value, td);
            }

            Save(Path.Combine(data.FullName, this.FileName));

            foreach (var world in this.WorldsList)
            {
                foreach (var map in world.Value.MapList)
                {
                    map.Value.Map.TextureName = dict[world.Value].dict[map.Value.Map].oldTexture;
                    map.Value.MapFileLocation = dict[world.Value].dict[map.Value.Map].oldPath;
                }
            }
        }
开发者ID:NullSoldier,项目名称:Valkyrie,代码行数:53,代码来源:WorldManager.cs

示例13: ModifyAppDirectory

        static void ModifyAppDirectory()
        {
            DirectoryInfo dir = new DirectoryInfo(@"C:\");

            // Create \MyFolder off application directory.
            dir.CreateSubdirectory("MyFolder");

            // Create \MyFolder2\Data off application directory.
            DirectoryInfo myDataFolder = dir.CreateSubdirectory(@"MyFolder2\Data");

            Console.WriteLine("New Folder is: {0}", myDataFolder);
        }
开发者ID:JamesPinkard,项目名称:WalkthroughSolutions,代码行数:12,代码来源:Program.cs

示例14: ModifyAppDirectory

        static void ModifyAppDirectory()
        {
            DirectoryInfo dir = new DirectoryInfo(".");

            // Create \MyFolder off initial directory.
            dir.CreateSubdirectory("MyFolder");

            // Capture returned DirectoryInfo object.
            DirectoryInfo myDataFolder = dir.CreateSubdirectory(@"MyFolder2\Data");

            // Prints path to ..\MyFolder2\Data.
            Console.WriteLine("New Folder is: {0}", myDataFolder);
        }
开发者ID:usedflax,项目名称:flaxbox,代码行数:13,代码来源:Program.cs

示例15: Main

        static void Main(string[] args)
        {
            string[] tabFichier = Directory.GetFiles(@"C:\Windows\Web\Wallpaper");

            foreach (string fichier in tabFichier)
                Console.WriteLine(fichier);

            Console.ReadLine();

            DirectoryInfo dir = new DirectoryInfo(@"C:\Windows\Web\Wallpaper");
            FileInfo[] tableauImages = dir.GetFiles("*.jpg");

            foreach (FileInfo f in tableauImages)
            {
                Console.WriteLine("***************************");
                Console.WriteLine("Nom Fichier: {0}", f.Name);
                Console.WriteLine("Taille: {0}", f.Length);
                Console.WriteLine("Création: {0}", f.CreationTime);
                Console.WriteLine("Attributs: {0}", f.Attributes);
                Console.WriteLine("***************************\n");
            }

            DirectoryInfo dir2 = new DirectoryInfo(".");

            // Mon Répertoire
            dir2.CreateSubdirectory(@"Mon Répertoire");

            // Mon Répertoire2
            DirectoryInfo nouveau = dir2.CreateSubdirectory
                (@"Mon Répertoire2\Données");

            DriveInfo[] mesDisques = DriveInfo.GetDrives();

            foreach (DriveInfo d in mesDisques)
            {
                Console.WriteLine("Nom: {0}", d.Name); // C ou D
                Console.WriteLine("Type: {0}", d.DriveType); // fixe

                if (d.IsReady)
                {
                    Console.WriteLine("Espace libre: {0}", d.TotalFreeSpace);
                    Console.WriteLine("Système fichier: {0}", d.DriveFormat);
                    Console.WriteLine("Nom: {0}\n", d.VolumeLabel);
                }
            }

            Console.ReadLine();


        }
开发者ID:drynish,项目名称:ecole,代码行数:50,代码来源:Program.cs


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