Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. using System.IO;
  2. ...
  3.  
  4. string path = @"C:MP_Upload";
  5. if(!Directory.Exists(path))
  6. {
  7. Directory.CreateDirectory(path);
  8. }
  9.  
  10. using System.IO;
  11. ...
  12.  
  13. Directory.CreateDirectory(@"C:MP_Upload");
  14.  
  15. if(!System.IO.Directory.Exists(@"c:mp_upload"))
  16. {
  17. System.IO.Directory.CreateDirectory(@"c:mp_upload");
  18. }
  19.  
  20. if(!Directory.Exists(@"C:MP_Upload")) {
  21. Directory.CreateDirectory(@"C:MP_Upload");
  22. }
  23.  
  24. using System;
  25. using System.IO;
  26. using System.Windows.Forms;
  27.  
  28. namespace DirCombination
  29. {
  30. public partial class DirCombination : Form
  31. {
  32. private const string _Path = @"D:/folder1/foler2/folfer3/folder4/file.txt";
  33. private string _finalPath = null;
  34. private string _error = null;
  35.  
  36. public DirCombination()
  37. {
  38. InitializeComponent();
  39.  
  40. if (!FSParse(_Path))
  41. Console.WriteLine(_error);
  42. else
  43. Console.WriteLine(_finalPath);
  44. }
  45.  
  46. private bool FSParse(string path)
  47. {
  48. try
  49. {
  50. string[] Splited = path.Replace(@"//", @"/").Replace(@"\", @"/").Replace(@"", "/").Split(':');
  51. string NewPath = Splited[0] + ":";
  52. if (Directory.Exists(NewPath))
  53. {
  54. string[] Paths = Splited[1].Substring(1).Split('/');
  55.  
  56. for (int i = 0; i < Paths.Length - 1; i++)
  57. {
  58. NewPath += "/";
  59. if (!string.IsNullOrEmpty(Paths[i]))
  60. {
  61. NewPath += Paths[i];
  62. if (!Directory.Exists(NewPath))
  63. Directory.CreateDirectory(NewPath);
  64. }
  65. }
  66.  
  67. if (!string.IsNullOrEmpty(Paths[Paths.Length - 1]))
  68. {
  69. NewPath += "/" + Paths[Paths.Length - 1];
  70. if (!File.Exists(NewPath))
  71. File.Create(NewPath);
  72. }
  73. _finalPath = NewPath;
  74. return true;
  75. }
  76. else
  77. {
  78. _error = "Drive is not exists!";
  79. return false;
  80. }
  81. }
  82. catch (Exception ex)
  83. {
  84. _error = ex.Message;
  85. return false;
  86. }
  87. }
  88. }
  89. }
  90.  
  91. String path = Server.MapPath("~/MP_Upload/");
  92. if (!Directory.Exists(path))
  93. {
  94. Directory.CreateDirectory(path);
  95. }
  96.  
  97. using System.IO;string path = "C:MP_Upload";if(!Directory.Exists(path)){
  98. Directory.CreateDirectory(path);}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement