CreateDirectory() 공개 정적인 메소드

public static CreateDirectory ( string directory ) : void
directory string
리턴 void
예제 #1
0
        public void CreateDirectory_GetAllFilePathsFromDirectory_DeleteAllFilesFromDirectory()
        {
            _fileManager.CreateDirectory(testDirectoryName);
            Assert.IsTrue(Directory.Exists(testDirectoryName));
            _fileManager.CreateDirectory(testDirectoryName);
            _fileManager.CreateDirectory(testDirectoryName);

            for (int i = 1; i <= 10; i++)
            {
                _fileManager.Write(string.Format("{0}\\{1}{2}.txt", testDirectoryName, authorFileName, i), "Dan Misailescu");
            }

            for (int i = 1; i <= 7; i++)
            {
                _fileManager.Write(string.Format("{0}\\{1}{2}.png", testDirectoryName, authorFileName, i), "Dan Misailescu");
            }

            var childDirectoryName = string.Format("{0}\\Child{{0}}", testDirectoryName);

            _fileManager.CreateDirectory(childDirectoryName);
            for (int i = 1; i <= 5; i++)
            {
                _fileManager.Write(string.Format("{0}\\{1}{2}.mp3", childDirectoryName, authorFileName, i), "Dan Misailescu");
            }

            Assert.AreEqual(17, _fileManager.GetAllFilesFromDirectory(testDirectoryName).Count);
            Assert.AreEqual(22, _fileManager.GetAllFilesFromDirectory(testDirectoryName, null, true).Count);
            Assert.AreEqual(0, _fileManager.GetAllFilesFromDirectory(testDirectoryName, new List <string> {
                ".jpg"
            }).Count);
            Assert.AreEqual(7, _fileManager.GetAllFilesFromDirectory(testDirectoryName, new List <string> {
                ".pNG"
            }).Count);

            _fileManager.DeleteAllFilesFromDirectory(testDirectoryName, new List <string> {
                ".mp3"
            });
            Assert.AreEqual(22, _fileManager.GetAllFilesFromDirectory(testDirectoryName, null, true).Count);
            _fileManager.DeleteAllFilesFromDirectory(testDirectoryName, new List <string> {
                ".mp3"
            }, true);
            Assert.AreEqual(17, _fileManager.GetAllFilesFromDirectory(testDirectoryName, null, true).Count);

            _fileManager.DeleteAllFilesFromDirectory(testDirectoryName, new List <string> {
                ".txt"
            });
            Assert.AreEqual(7, _fileManager.GetAllFilesFromDirectory(testDirectoryName, null, true).Count);

            _fileManager.DeleteAllFilesFromDirectory(testDirectoryName);
            Assert.AreEqual(0, _fileManager.GetAllFilesFromDirectory(testDirectoryName).Count);

            Directory.Delete(testDirectoryName, true);
        }
예제 #2
0
        public Player CreatePlayer(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(name, "Name des Spielers darf nicht leer sein.");
            }

            int    playerId         = this.Players.Count;
            string playerFolderName = string.Format("{0}_{1}", PlayerFolderPrefix, playerId);

            string directoryPath = Path.Combine(ConfigManager.Current.GameDirectoryPath, playerFolderName);

            FileManager.CreateDirectory(directoryPath);

            string playerConfigName = string.Format("{0}_{1}.cfg", PlayerFolderPrefix, playerId);
            string configFilePath   = Path.Combine(directoryPath, playerConfigName);

            FileManager.Create(configFilePath);

            Player p = new Player(playerId, name, directoryPath, configFilePath);

            this.Players.Add(p);

            ConfigManager.Current.GameConfig.PlayersConfigPath.Add(configFilePath);

            // Save new Player
            SavePlayers();
            ConfigManager.Current.SaveGameConfig();

            return(p);
        }
예제 #3
0
    public static void Main()
    {
        FileManager newfile = new FileManager();

        // Create a new directory
        newfile.FilePath = @"files/file-folder"; // directory name
        newfile.CreateDirectory();

        // Write file in newly created directory
        newfile.FilePath = @"files/file-folder/another.txt"; // directory and file name
        newfile.CreateAndWriteFile();

        // Read from the newly created file
        newfile.FilePath = @"files/file-folder/another.txt";
        newfile.ReadFromFile();

        // Copy to new directory
        string source      = @"files/file-folder";
        string destination = @"files/another-folder";

        newfile.CopyToAnotherDirectory(source, destination, "another.txt");

        // Delete file
        newfile.FilePath = @"files/file-folder/another.txt";
        newfile.DeleteFile();

        // Delete directory
        newfile.FilePath = @"files/file-folder";
        newfile.DeleteDirectory();
    }
예제 #4
0
 /// <summary>
 /// Makes sure the settings folder exists on disk. Doesn't add the folder to
 /// the project.
 /// </summary>
 protected void EnsureSettingsFolder()
 {
     if (!FileManager.DirectoryExists(LaunchSettingsFileFolder))
     {
         FileManager.CreateDirectory(LaunchSettingsFileFolder);
     }
 }
예제 #5
0
        private void ButtonSave_Click(object sender, RoutedEventArgs e)
        {
            switch (this.Type)
            {
            case 0:
                if (FileManager.CreateFile(Path, FileNameTextBox.Text) != null)
                {
                    this.Close();
                }
                break;

            case 1:
                FileManager.Rename(new FileInfo(Path), FileNameTextBox.Text);
                this.Close();
                break;

            case 2:
                if (FileManager.CreateDirectory(Path, FileNameTextBox.Text) != null)
                {
                    this.Close();
                }
                break;

            case 3:
                FileManager.Rename(new DirectoryInfo(Path), FileNameTextBox.Text);
                this.Close();
                break;

            default:
                break;
            }
        }
예제 #6
0
        private void OnDownOver()
        {
            FileManager.CreateDirectory(m_savePath);
            if (File.Exists(m_savePath + Config.BundleManifest))
            {
                File.Delete(m_savePath + Config.BundleManifest);
            }
            File.Move(m_temPath + Config.BundleManifest, m_savePath + Config.BundleManifest);
            var assets = (Dictionary <string, JsonNode>)m_root["BundleManifest"];
            var eor    = assets.GetEnumerator();

            while (eor.MoveNext())
            {
                string name = eor.Current.Value["BundleName"].ToString();
                if (File.Exists(m_temPath + name))
                {
                    if (File.Exists(m_savePath + name))
                    {
                        File.Delete(m_savePath + name);
                    }

                    File.Move(m_temPath + name, m_savePath + name);
                }
            }
            eor.Dispose();
            FileManager.ClearFiles(m_temPath);
        }
예제 #7
0
        /// <summary>
        /// 保存md5文件 都更新成功后保存
        /// </summary>
        /// <param name="tabDictionary"></param>
        private void SaveMD5Table(Dictionary <string, FileInfo> tabDictionary)
        {
            string filename = Platform.Path + Platform.Md5FileName;

            if (FileManager.IsFileExist(filename))
            {
                FileManager.DeleteFile(filename);
            }
            string directory = Path.GetDirectoryName(filename);

            if (!string.IsNullOrEmpty(directory) && !FileManager.IsDirectoryExist(directory))
            {
                FileManager.CreateDirectory(directory);
            }
            try
            {
                using (var write = new StreamWriter(new FileStream(filename, FileMode.Create)))
                {
                    foreach (KeyValuePair <string, FileInfo> keyValuePair in tabDictionary)
                    {
                        write.WriteLine(keyValuePair.Key + "," + keyValuePair.Value.md5 + "," + keyValuePair.Value.size);
                    }
                }
            }
            catch (Exception e)
            {
                Debuger.LogError(e.Message);
            }
        }
        public void CreateDirectory(string directoryName)
        {
            var fullPath = "{0}/{1}".FormatString(CurrentDirectory, directoryName);

            FileManager.CreateDirectory(fullPath);
            Action?.Invoke(CurrentDirectory);
        }
예제 #9
0
        public static void CreateClassFileForGivenTypeClass(string ClassName, string strCode, ICD CodeType)
        {
            string RootlibraryPath = SavePath;

            FileManager.CreateDirectory(RootlibraryPath);
            string infoPath = RootlibraryPath;

            switch (CodeType)
            {
            case ICD.Info:
                infoPath = infoPath + "/Info";
                break;

            case ICD.Controller:
                infoPath = infoPath + "/Controller";
                break;

            case ICD.DataProvider:
                infoPath = infoPath + "/DataProvider";
                break;

            default:
                break;
            }

            FileManager.CreateDirectory(infoPath);
            string destinationPath = infoPath + "/" + ClassName + ".cs";

            using (StreamWriter sw = new StreamWriter(destinationPath))
            {
                sw.Write(strCode);
            }
        }
예제 #10
0
        //inizializza un nuovo progetto a livello di file
        bool NewProject()
        {
            //Apre il dialog e sceglie la cartella in cui inserirlo
            string dirPath;

            if (FileManager.Browse_Folder("Scegli la cartella in cui creare la cartella del progetto)", out dirPath))
            {
                if (new SaveForm(setting).ShowDialog() == DialogResult.OK)
                {
                    //creazione delle cartelle e dei file---> se non li crea tutti ritorna falso
                    string[] outPath = new string[2];
                    if (
                        !FileManager.CreateDirectory(dirPath, names[2], true) ||
                        !FileManager.CreateNewFile(out outPath[0], dirPath + @"\" + names[2], names[0], ".html", defaultHTML_Content, true) ||
                        !FileManager.CreateNewFile(out outPath[1], dirPath + @"\" + names[2], names[1], ".css", defaultCSS_Content, true)
                        )
                    {
                        return(false);
                    }

                    //Caricamento degli indirizzi
                    FilePaths = outPath;

                    //caricamento della finestra
                    if (Extract())
                    {
                        //imposta il collegamento al file di css
                        PlaceLink();
                    }
                }
                return(true);    //-------> se ritornasse false apparirebbe la messageBox di errore anche se la creazione è stata abrogata
            }
            return(false);
        }
예제 #11
0
        public void Draw(Configuration configuration)
        {
            SchemaEntity schema;

            using (var fileStream = FileManager.OpenFileStream(configuration.SchemaFilePath))
            {
                schema = _schemaReader.Read(fileStream);
            }

            var points = _pointPositionCalculator.Handle(schema);

            if (FileManager.IsExist(configuration.DirectoryPath))
            {
                throw new Exception("Такая папка уже существует");
            }
            FileManager.CreateDirectory(configuration.DirectoryPath);
            FileManager.CopyFile("readme.md", Path.Combine(configuration.DirectoryPath, "readme.md"));
            using (var repo = new Repository(Repository.Init(configuration.DirectoryPath)))
            {
                Commands.Stage(repo, "readme.md");
                var maxCommitsCount = configuration.MaxCommitsCount > 4 ? configuration.MaxCommitsCount : 4;
                _commitCreator.Create(points, repo, maxCommitsCount, configuration.FileName, configuration.UserName,
                                      configuration.UserEmail);
            }
        }
예제 #12
0
        /// <summary>
        /// Makes sure the settings folder exists on disk. Doesn't add the folder to
        /// the project.
        /// </summary>
        protected async Task EnsureSettingsFolderAsync()
        {
            string fileName = await GetLaunchSettingsFilePathAsync();

            string parentPath = Path.GetDirectoryName(fileName);

            FileManager.CreateDirectory(parentPath);
        }
예제 #13
0
 private void button_CreateDir_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(textBox_nameDir.Text))
     {
         FM.CreateDirectory(Path, textBox_nameDir.Text.FixForbidCharInTerminal().EncodingText());
         IsChangeValue = true;
     }
     this.Close();
 }
예제 #14
0
        /// <summary>
        /// Makes sure the settings folder exists on disk. Doesn't add the folder to
        /// the project.
        /// </summary>
        protected void EnsureSettingsFolder()
        {
            var launchSettingsFileFolderPath = Path.Combine(Path.GetDirectoryName(CommonProjectServices.Project.FullPath), LaunchSettingsFileFolder);

            if (!FileManager.DirectoryExists(launchSettingsFileFolderPath))
            {
                FileManager.CreateDirectory(launchSettingsFileFolderPath);
            }
        }
예제 #15
0
        /// <summary>
        /// Makes sure the settings folder exists on disk. Doesn't add the folder to
        /// the project.
        /// </summary>
        protected async Task EnsureSettingsFolderAsync()
        {
            string fileName = await _launchSettingsFilePath.GetValueAsync()
                              .ConfigureAwait(false);

            string parentPath = Path.GetDirectoryName(fileName);

            FileManager.CreateDirectory(parentPath);
        }
예제 #16
0
 /// <summary>
 /// Creates a directory with the given <paramref name="path"/>
 /// </summary>
 /// <param name="path"></param>
 /// <returns>Returns true if successful in creating the directory</returns>
 internal bool AddFolder(string path)
 {
     if (fileManager.CreateDirectory(path))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #17
0
 private static void GetDirectory(string path)
 {
     try
     {
         FileManager.CreateDirectory(path);
     }
     catch (Exception e)
     {
         Logger.Error("Error getting directory[" + path + "]. Reason - " + e.Message);
     }
 }
예제 #18
0
 private void CreateCurrentGameFolder()
 {
     if (this.CurrentPlayer != null)
     {
         string timeStamp = DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss");
         string path      = Path.Combine(this.CurrentPlayer.DirectoryPath, timeStamp);
         if (FileManager.CreateDirectory(path))
         {
             this.CurrentPlayer.CurrentGameFolderPath = path;
         }
     }
 }
예제 #19
0
        public void ListCompatibleBgInfos()
        {
            fm.CreateDirectory(bgInfosPath);
            fm.CreateDirectory(dumpsPath);
            fm.CreateDirectory(amsPath);

            int bgFileInfosCount = fm.LoadFiles(bgInfosPath, "json");

            BgFileInfos.Clear();

            //List only the Bg info which has a mask AND using an alt mask source.
            BgInfo[] bgFileInfoCandidates = fm.GetObjectsFromFiles <BgInfo>();
            for (int i = 0; i < bgFileInfosCount; i++)
            {
                BgInfo bgInfo = bgFileInfoCandidates[i];

                //It needs to be a BG with a mask AND using an alt mask source
                if (bgInfo.hasMask == false || bgInfo.useProcessedMaskTex == false)
                {
                    continue;
                }

                //It needs to have its BG image and BG AMS image present in dump/AMS folders
                if (fm.GetBitmapFromPath(Path.Combine(dumpsPath, bgInfo.namePrefix)) == null)
                {
                    continue;
                }

                if (fm.GetBitmapFromPath(Path.Combine(amsPath, bgInfo.namePrefix + "_altMaskSource")) == null)
                {
                    continue;
                }

                //I need to add an underscore due to some nmemonic thingy with wpf. If I don't the next _ will get escaped.
                BgFileInfos.Add(new BgFileInfo()
                {
                    DisplayName = "_" + bgInfo.namePrefix, Fi = fm.fileInfos[i], Index = i
                });
            }
        }
예제 #20
0
 static public int CreateDirectory_s(IntPtr l)
 {
     try {
         System.String a1;
         checkType(l, 1, out a1);
         FileManager.CreateDirectory(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #21
0
    static void BuildSharedAssetBundle(string path, Object[] resources)
    {
#if UNITY_5_3
#else
        FileManager.CreateDirectory(System.IO.Path.GetDirectoryName(path));

        if (BuildPipeline.BuildAssetBundle(null, resources, path, _buildOptions, _buildTarget))
        {
            Debug.Log(path + "资源打包成功");
        }
        else
        {
            Debug.Log(path + "资源打包失败");
        }
#endif
    }
예제 #22
0
        /// <summary>
        ///     Install the update.
        /// </summary>
        private void InstallUpdate()
        {
            if (Directory.Exists(_installOptions.InstallFilesFolder))
            {
                Directory.Delete(_installOptions.InstallFilesFolder, true);
            }

            FileManager.CreateDirectory(_installOptions.InstallFilesFolder);

            foreach (string _archive in _installOptions.DownloadedFiles)
            {
                ZipFile.ExtractToDirectory(_archive, _installOptions.InstallFilesFolder);
            }

            CompileInstaller(_installOptions);
        }
예제 #23
0
    private void Start()
    {
        frameCount = 0;
        texture2D  = new Texture2D(mainCamera.pixelWidth, mainCamera.pixelHeight, TextureFormat.RGBA32, false);

        fm.CreateDirectory(path);

        introFrameCount = fm.LoadFiles(pathIntro, "png", System.IO.SearchOption.TopDirectoryOnly);
        fm.fileInfos    = fm.fileInfos.OrderBy(x => x.CreationTime).ToArray();
        introFrameNames = new string[introFrameCount];

        for (int i = 0; i < introFrameCount; i++)
        {
            introFrameNames[i] = fm.RemoveExtensionFromFileInfo(fm.fileInfos[i]);
        }
    }
예제 #24
0
 public void EncryptFile()
 {
     if (SelectedFile != null && SelectedCategory != null)
     {
         FM.CreateDirectory(SelectedCategory);
         var category    = FM.GetCategory(SelectedCategory);
         var destination = category.FullName + $"\\{SelectedFile.Name}{SelectedFile.Extension}";
         if (!File.Exists(destination))
         {
             try
             {
                 FM.Encrypt(Password, SelectedFile, destination);
                 if (DeleteFileChecked)
                 {
                     FM.DeleteFile(SelectedFile.FullName);
                 }
                 Shell.WindowManager.ShowMessageBox($"Successfully Encrypted {SelectedFile.Name}{SelectedFile.Extension}");
             }
             catch (Exception)
             {
                 Shell.WindowManager.ShowMessageBox("Failed to Encrypt File");
             }
             finally
             {
                 Close();
             }
         }
         else
         {
             Shell.WindowManager.ShowMessageBox("Encrypted file with this name and category already exists.");
         }
     }
     else
     {
         StringBuilder message = new StringBuilder();
         message.Append("Could not encrypt file: \n");
         if (SelectedFile == null)
         {
             message.Append("No file added\n");
         }
         if (SelectedCategory == null)
         {
             message.Append("No category selected.\n");
         }
         Shell.WindowManager.ShowMessageBox(message.ToString());
     }
 }
예제 #25
0
        //更新资源
        private void DownloadNewResources()
        {
            FileManager.CreateDirectory(m_temPath);
            FileLoadAgent agent = new FileLoadAgent();

            Dictionary <string, DownState> downloaded = new Dictionary <string, DownState>();

            if (File.Exists(m_temPath + "download.list"))
            {
                ParseDownloadList(downloaded, agent);
            }

            JsonNode root = null;

            if (File.Exists(m_temPath + Config.BundleManifest))
            {
                root = new JsonParser().Load(agent.Load(m_temPath + Config.BundleManifest));
                if (root.IsTable())
                {
                    string ver = root["Version"].ToString();
                    if (ver.Equals(m_remoteVersion))
                    {
                    }
                    else
                    {
                        root = null;
                    }
                }
                else
                {
                    root = null;
                }
            }

            if (root == null)
            {
                DownLoadManifest(() =>
                {
                    root = new JsonParser().Load(agent.Load(m_temPath + Config.BundleManifest));
                    CombineDownloadList(root, downloaded);
                });
            }
            else
            {
                CombineDownloadList(root, downloaded);
            }
        }
예제 #26
0
        public MainWindow()
        {
            DataContext = this;

            InitializeComponent();

            Fs = fm.GetObjectFromPath <FolderStructure>("./config.json");

            OnPropertyChanged(nameof(Fs));

            fm.CreateDirectory("./dependencies");
        }
        public void LoadGameConfig()
        {
            if (!Directory.Exists(this.GameDirectoryPath))
            {
                FileManager.CreateDirectory(this.GameDirectoryPath);
            }

            if (!File.Exists(this.GameConfigPath))
            {
                CreateGameConfig(this.GameConfigPath);
                this.GameConfig = new GameConfig();
            }
            else
            {
                string content = FileManager.Read(this.GameConfigPath);
                this.GameConfig = JsonUtility.FromJson <GameConfig>(content);
            }
        }
        public void CreateRepositoryWithCommits()
        {
            var points = new List <PointPosition>
            {
                new PointPosition(0, 0, Saturation.Light, new DateTime(2017, 9, 24))
            };

            const string workingDirectoryPath = "test";

            if (FileManager.IsExist(workingDirectoryPath))
            {
                FileManager.RemoveDirectory(workingDirectoryPath);
            }
            FileManager.CreateDirectory(workingDirectoryPath);
            using (var repo = new Repository(Repository.Init(workingDirectoryPath)))
            {
                CommitCreator.Create(points, repo, 4, "test_file.txt", "TestUserName", "*****@*****.**");
            }
        }
예제 #29
0
    public static void WriteLuaMemoryInfoToFile(int type, string memorySnapshot)
    {
        if (type == 0)
        {
            Debug.Log(string.Format("lua 虚拟机占用总内存{0}kb", memorySnapshot));
            return;
        }
        DirectoryInfo dirInfo    = new DirectoryInfo(Application.dataPath);
        string        fileFolder = dirInfo.Parent + "/LuaMemorySnapShotFiles";

        if (!FileManager.DirectoryExist(fileFolder))
        {
            FileManager.CreateDirectory(fileFolder);
        }
        string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";
        string filePath = fileFolder + "/" + fileName;

        FileManager.WriteAllText(filePath, memorySnapshot);
    }
예제 #30
0
    static void BuildAssetBundle(string path, Object[] resources)
    {
#if UNITY_5_3
#else
        BuildPipeline.PushAssetDependencies();

        FileManager.CreateDirectory(Path.GetDirectoryName(path));

        if (BuildPipeline.BuildAssetBundle(null, resources, path, _buildOptions, _buildTarget))
        {
            Debug.Log(path + "资源打包成功");
        }
        else
        {
            Debug.Log(path + "资源打包失败");
        }

        BuildPipeline.PopAssetDependencies();
#endif
    }