我有一个没有 get & set Methode 的 CButtonCreate 类。但我想在另一个类即WriteToFile类中使用来自类CButtonCreate的属性“string newFileName”。如何在类 WriteToFile 中使用属性 newFileName?
class CButtonCreate
{
// Create a Folder && SubFolder from the tbProject
public void CreateFolder(string MyFolderName, string Mytbs, string MytbRevision, string MyTestSystem)
{
// Open the Directory path
string activeDir = @"Y:\temp";
//Combine the current active folder with the tbProject
string newPath = Path.Combine(activeDir, MyFolderName);
// Create a folder in the active Directory
Directory.CreateDirectory(newPath);
// Create a new SubFolder name. This example generates a random string. "tbs"
string newSubPath = Path.Combine(newPath, Mytbs);
//Create a new Subfolder under the current active folder
Directory.CreateDirectory(newSubPath);
// Create a new file name.
string newFileName = "Project_" + MyFolderName + "_" + MytbR + ".txt";
// Combine the new file name with the path
newPath = System.IO.Path.Combine(newPath, newFileName);
if (!System.IO.File.Exists(newPath))
{
using (System.IO.FileStream fs = System.IO.File.Create(newPath))
{
// Call the Function WriteInFile
}
}
}
class WriteToFile
{
public void WriteInFile(string MyFolderName, string MytextBox, string MytbR, string MycbTest)
{
CButtonCreate myFile = new CButtonCreate();
StreamWriter sw = new StreamWriter(newFileName);
}
}