G Guest Apr 19, 2005 #1 I want to create a new directory in a given path and need to create a file in that new directory. Any ideas?
I want to create a new directory in a given path and need to create a file in that new directory. Any ideas?
G Guest Apr 19, 2005 #2 using System.IO; string strPath = "what your physical path is"; //ie "C:\\Windows\\System32" try { if (Directory.Exists(strPath)) { lblDirectoryResult.Text += "That path " + strPath + " already exists."; return; } DirectoryInfo di = Directory.CreateDirectory(strPath); lblDirectoryResult.Text += "The directory " + strPath + " was created successfully."; } catch (Exception ex) { lblDirectoryResult.Text = Convert.ToString(ex.Message); } Good luck!
using System.IO; string strPath = "what your physical path is"; //ie "C:\\Windows\\System32" try { if (Directory.Exists(strPath)) { lblDirectoryResult.Text += "That path " + strPath + " already exists."; return; } DirectoryInfo di = Directory.CreateDirectory(strPath); lblDirectoryResult.Text += "The directory " + strPath + " was created successfully."; } catch (Exception ex) { lblDirectoryResult.Text = Convert.ToString(ex.Message); } Good luck!
G Guest Apr 20, 2005 #3 THanks mate. This helps a lot. No Spam said: using System.IO; string strPath = "what your physical path is"; //ie "C:\\Windows\\System32" try { if (Directory.Exists(strPath)) { lblDirectoryResult.Text += "That path " + strPath + " already exists."; return; } DirectoryInfo di = Directory.CreateDirectory(strPath); lblDirectoryResult.Text += "The directory " + strPath + " was created successfully."; } catch (Exception ex) { lblDirectoryResult.Text = Convert.ToString(ex.Message); } Good luck! Click to expand...
THanks mate. This helps a lot. No Spam said: using System.IO; string strPath = "what your physical path is"; //ie "C:\\Windows\\System32" try { if (Directory.Exists(strPath)) { lblDirectoryResult.Text += "That path " + strPath + " already exists."; return; } DirectoryInfo di = Directory.CreateDirectory(strPath); lblDirectoryResult.Text += "The directory " + strPath + " was created successfully."; } catch (Exception ex) { lblDirectoryResult.Text = Convert.ToString(ex.Message); } Good luck! Click to expand...