If you need to create a new directory under the folder of program files, how do you know it is in the path of C or D drive? Can you write C# to create a new folder? You can use ExpandEnvironmentVariables to get the path:
public string DataPath = Environment.ExpandEnvironmentVariables(@"%ProgramFiles%\TestData");
If you want to create a new folder , you can use this key word: Directory.
if (!Directory.Exists(DataPath))
{
Directory.CreateDirectory(DataPath);
}
If you want to add a new file, you can use this key word : File
File .Create(DataPath + @"\test.txt");
No comments:
Post a Comment