Dim strTestExample As String
Private colTestExample As Collection
If(FileExists(strFullFile) Then
Open strTestExample For Input As #intFILE
Do While Not EOF(intTEST)
Input #intFILE, strFirstName, strLastName, strFavColor, strAge
Set objTestObject = New PracticeExample
With objTestObject
.FirstName = strFirstName
.LastName = strLastName
.FavColor = strFavColor
.Age = strAge
colTestExample.Add objTestObject, .FirstName
End With
Loop
Close #intFILE
End If
经过无数次尝试在C#中重新创建它,是时候我咨询全能的力量了。我尝试使用FileSystemObject
打开并写入文件。我试图将其移植到C#。我相信没有检查我在.NET 4.0中工作。
如果您想进一步阐述,请在下面提问。内容正在输入.txt文件。
C#尝试:
string Path;
string FullFile;
const string FileName = "People.txt";
TextStream TS;
FileSystemObject FSO = new FileSystemObject();
PracticeExample objTestObject = new PracticeExample();
Path = AppDomain.CurrentDomain.BaseDirectory;
File = FileSystem.FreeFile();
FullFile = Path + "\"" + FileName;
if (File.Exists(FullFile) == true)
{
FileSystem.FileOpen(File, strFirstName, strLastName, strFavColor, strAge);
TS = FSO.OpenTextFile(File.ToString(), IOMode.ForWriting, true);
FSO.
objTestObject.FirstName = strFirstName;
objTestObject.LastName = strLastName;
objTestObject.FavColor = strFavColor;
objTestObject.Age = strAge;
HashTableRouteDefinitions.Add(objTestObject,objTestObject.FirstName);
FileSystem.FileClose(File);
}
我在PracticeExample中有getter和setter。(警告,未完成的代码。)