CreateDirectory









How do I use Create Directory
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: PhotonConverter.cs Copy
341     static void EnsureFolder(string path)
342     {
343         if (!Directory.Exists(path))
344         {
345             Directory.CreateDirectory(path);
346             AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
347             AssetDatabase.Refresh();
348         }
349     }
File name: PhotonEditor.cs Copy
827     {
828         get
829         {
830             if (currentSettings == null)
831             {
832                 // find out if ServerSettings can be instantiated (existing script check)
833                 ScriptableObject serverSettingTest = CreateInstance("ServerSettings");
834                 if (serverSettingTest == null)
835                 {
836                     Debug.LogError(CurrentLang.ServerSettingsMissingLabel);
837                     return null;
838                 }
839                 DestroyImmediate(serverSettingTest);
840
841                 // try to load settings from file
842                 ReLoadCurrentSettings();
843
844                 // if still not loaded, create one
845                 if (currentSettings == null)
846                 {
847                     string settingsPath = Path.GetDirectoryName(PhotonNetwork.serverSettingsAssetPath);
848                     if (!Directory.Exists(settingsPath))
849                     {
850                         Directory.CreateDirectory(settingsPath);
851                         AssetDatabase.ImportAsset(settingsPath);
852                     }
853
854                     currentSettings = (ServerSettings)ScriptableObject.CreateInstance("ServerSettings");
855                     if (currentSettings != null)
856                     {
857                         AssetDatabase.CreateAsset(currentSettings, PhotonNetwork.serverSettingsAssetPath);
858                     }
859                     else
860                     {
861                         Debug.LogError(CurrentLang.ServerSettingsMissingLabel);
862                     }
863                 }
864
865                 // settings were loaded or created. set this editor's initial selected region now (will be changed in GUI)
866                 if (currentSettings != null)
867                 {
868                     selectedRegion = currentSettings.PreferredRegion;
869                 }
870             }
871
872             return currentSettings;
873         }
874
875         protected set
876         {
877             currentSettings = value;
878         }
879     }
File name: frmMainMenu.cs Copy
367         private void backupToolStripMenuItem_Click(object sender, EventArgs e)
368         {
369             try
370             {
371                 Cursor = Cursors.WaitCursor;
372                 timer2.Enabled = true;
373                 if ((!System.IO.Directory.Exists("C:\\DBBackup")))
374                 {
375                     System.IO.Directory.CreateDirectory("C:\\DBBackup");
376                 }
377                 string destdir = "C:\\DBBackup\\pos_db " + DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss") + ".bak";
378                 con = new SqlConnection(cs.DBConn);
379                 con.Open();
380                 string cb = "backup database [" + System.Windows.Forms.Application.StartupPath + "\\pos_db.mdf] to disk='" + destdir + "'with init,stats=10";
381                 cmd = new SqlCommand(cb);
382                 cmd.Connection = con;
383                 cmd.ExecuteReader();
384                 con.Close();
385                 MessageBox.Show("Successfully performed", "Database Backup", MessageBoxButtons.OK, MessageBoxIcon.Information);
386             }
387             catch (Exception ex)
388             {
389                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
390             }
391         }

CreateDirectory 105 lượt xem

Gõ tìm kiếm nhanh...